Writing a timer event (how to execute an event from time to time)

Rogério Schneider stockrt at gmail.com
Tue May 25 18:08:01 MSD 2010


> Can't say for 0.7.x, but in 0.8 the request may be cleaned up before the last
> buffer is sent. For example, returning NGX_ERROR from a handler would lead to
> the request cleanup as soon as possible. It may be false for 0.7.
>
> Setting up a cleanup handler seems to be a good thing to do anyway ;)
> Like so:
>
> ngx_http_cleanup_t        *cln;
>
> cln = ngx_http_cleanup_add(r, 0);
> if (cln == NULL) {
>    return NGX_ERROR;
> }
>
> cln->data = r;
> cln->handler = cleanup_handler;
>
>
> static void
> cleanup_handler(void *data) {
>    ngx_http_request_t        *r;
>    r = data;
>
>    // here get the module context ant delete the timer
> }

I see. I will learn how to handle ctx and cln and will try it. Wish it
get me free of segfaults then :)

Thanks,
-- 
Rogério Schneider
http://stockrt.github.com



More information about the nginx-devel mailing list