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
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to