Welcome! Log In Create A New Profile

Advanced

Re: Only fire a handler once

Aaron Bedra
September 05, 2013 10:24AM
Thanks!


On Wed, Sep 4, 2013 at 4:38 PM, Yichun Zhang (agentzh) <agentzh@gmail.com>wrote:

> Hello!
>
> On Fri, Aug 16, 2013 at 10:28 PM, Aaron Bedra wrote:
> > I'm looking for a way to make sure a handler only fires once.
>
> If your handler is possible to run multiple times for the same request
> (like the post_subrequest handlers) and you want to avoid that, you
> can just use a module ctx field to serve as a flag for that. For
> example,
>
> ctx = ngx_http_get_module_ctx(r, ngx_http_foo_module);
> if (ctx == NULL) {
> /* create ctx here and ctx->already_run should be initialized to 0
> */
> }
>
> if (ctx->already_run) {
> return NGX_DONE;
> }
> /* first time */
> ctx->already_run = 1;
>
> /* process normally */
>
> Regards,
> -agentzh
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Only fire a handler once

Aaron Bedra 895 August 17, 2013 01:30AM

Re: Only fire a handler once

Aaron Bedra 397 August 22, 2013 11:56AM

Re: Only fire a handler once

Yichun Zhang (agentzh) 364 September 04, 2013 05:40PM

Re: Only fire a handler once

Aaron Bedra 439 September 05, 2013 10:24AM



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

Online Users

Guests: 241
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