Welcome! Log In Create A New Profile

Advanced

Re: question about ngx_http_named_location

Maxim Dounin
August 31, 2012 02:54PM
Hello!

On Wed, Aug 29, 2012 at 02:43:04PM +0300, Anatoli Marinov wrote:

> Hello Mates,
> I am wondering why in ngx_http_named_location is used a segment of
> code that resets all modules contexts. I mean the line
> ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);.
> My opinion is that the module context should not be touched outside
> of the certain module. Is there a special reason for this patch? Is
> there a case which requires it?

There was more than one case where not clearing of module
contexts in ngx_http_named_location() was causing problems, see
here for more details:

http://mailman.nginx.org/pipermail/nginx-devel/2011-October/001329.html

As this behaviour wasn't something designed (rather a bug, even if
not affecting official modules), nor something consistent with
other similar code (i.e. clearing module contexts on internal
redirects), hence it was decided that it's better to clear context
than to don't.

As for clearing module contexts on internal redirects (in contrast
to named locations - where behaviour was changed recently, and the
change is explained above), it allows to simplify module
development as modules don't need to keep track of request
processing history. And actually it semantically does what internal
redirect is expected to do: start another request with another
uri.

There is at least one way to preserve data between both internal
redirects and named location changes (as well as subrequests,
actually), via variables. (It's somewhat a hack, but it works and
it's expected to work. You may try searching mailing list
archives for more details, I believe I explained this at least
once.)

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

question about ngx_http_named_location

toli 1408 August 29, 2012 07:44AM

Re: question about ngx_http_named_location

Vladimir Shebordaev 661 August 29, 2012 08:50AM

Re: question about ngx_http_named_location

toli 889 August 29, 2012 09:04AM

Re: question about ngx_http_named_location

Vladimir Shebordaev 753 August 29, 2012 02:44PM

Re: question about ngx_http_named_location

VBart 1142 August 29, 2012 02:56PM

Re: question about ngx_http_named_location

Maxim Dounin 645 August 31, 2012 02:54PM

Re: question about ngx_http_named_location

agentzh 789 August 31, 2012 06:34PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 149
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready