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

Maxim Dounin mdounin at mdounin.ru
Tue May 25 17:13:29 MSD 2010


Hello!

On Tue, May 25, 2010 at 08:35:15AM -0300, Rogério Schneider wrote:

> > Each request may clean its pool when finalizing the request. And the timer
> > uses the pool attached with that request. This caused the segfaults.
> 
> In fact the segfault occurs before the request/response end. Since I
> am responding with http chunked, and buf->last_buf = 0, the client
> stills connected and "downloading the stream" for an infinite time.

Not setting last_buf doesn't mean that request will not be 
finalized and freed.  As soon as you return from content handler - 
ngx_http_finalize_request() will be called, and it will free 
request as long as r->main->count == 1.

If you want request to persist for other actions - you have to 
increment r->main->count (and decrement it via calling 
ngx_http_finalize_request() once you're done) and return NGX_DONE 
from content handler.

See memcached (+ upstream) module, and perl module for examples in 
nginx code.  Set ngx_http_request.c and ngx_http_core_module.c for 
details about request processing.

Maxim Dounin



More information about the nginx-devel mailing list