[PATCH] clear modules' contexts in ngx_http_named_location

agentzh agentzh at gmail.com
Thu Oct 13 07:10:25 UTC 2011


Here attaches a patch for the nginx 1.1.5 core to fix a long standing
bug in the ngx_http_named_location function.

I think we should clear out all the modules' contexts there just as in
ngx_http_internal_redirect, or we'll observe weird issues due to
left-over obsolete module contexts from the original request before
the jump. Here is a bad case in action:


--- nginx-1.1.5/src/http/ngx_http_core_module.c	2011-09-27
19:14:02.000000000 +0800
+++ nginx-1.1.5-patched/src/http/ngx_http_core_module.c	2011-10-13
15:02:24.414550532 +0800
@@ -2542,6 +2542,9 @@
             r->content_handler = NULL;
             r->loc_conf = (*clcfp)->loc_conf;

+            /* clear the modules contexts */
+            ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);

             cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx-1.1.5-named_location_clear_mods_ctx.patch
Type: application/octet-stream
Size: 533 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20111013/440ebeb9/attachment.obj>

More information about the nginx-devel mailing list