Handling module ctx reset on internal redirect

Pillai, Saju saju.pillai at concur.com
Tue Feb 14 15:25:49 UTC 2017


Hello,

I am new to nginx and will appreciate some insight on handling the resetting of
module ctx during internal redirects.

Specifically, I have a module that runs in the HTTP_POST_READ_PHASE to build
some objects in memory, which it hangs off the request object via
ngx_http_set_ctx(r,..). These memory objects back new variables created by this
module.

After an internal redirect, when a filter tries to access the variables, my
handler is unable to find the ctx object via a ngx_http_get_module_ctx(). I see
that ngx_http_core_module.c:ngx_http_internal_redirect() zeros out all module
contexts during an internal redirect, and that makes sense. The (appropriate)
contexts will have to be rebuilt by modules that run for that internal redirect.

Since HTTP_POST_READ_PHASE handlers dont run on a redirect, how should I setup
my ctx so I can still access it after a redirect? I could create a r->pool
cleanup function and hang my ctx in the ngx_pool_cleanup_t->data slot; but that
seems like a workaround.

-srp


________________________________

This e-mail message is authorized for use by the intended recipient only and may contain information that is privileged and confidential. If you received this message in error, please call us immediately at (425) 590-5000 and ask to speak to the message sender. Please do not copy, disseminate, or retain this message unless you are the intended recipient. In addition, to ensure the security of your data, please do not send any unencrypted credit card or personally identifiable information to this email address. Thank you.


More information about the nginx-devel mailing list