Welcome! Log In Create A New Profile

Advanced

Re: handle NGX_AGAIN properly

Yichun Zhang (agentzh)
July 09, 2013 09:04PM
Hello!

On Tue, Jul 9, 2013 at 5:12 PM, Julien Zefi wrote:
> But if in some triggered callback by the timer the
> ngx_http_output_filter(..) returns NGX_AGAIN *i assume* NginX will send that
> chain as soon as the socket becomes available again.

This assumption is not correct. Nginx will only flush out the pending
data for you when r->write_event_handler is set to ngx_http_writer.
This only (automatically) happens in ngx_http_finalize_request (by
calling the ngx_http_set_write_handler function to do the assignment
to r->write_event_handler).

> But after that happens,
> how can i restore my timer cycle ?
>

My suggestion is to register your own r->write_event_handler handler
to propagate the pending outputs by calling ngx_http_output_filter
with a NULL chain link pointer yourself. And in that handler, you can
also restore your timer cycle and etc when all the pending outputs
have been flushed out (into the system socket send buffers).

I've been doing something like this in our ngx_lua module. You can
check out the ngx.flush() API function's implementation in particular:

http://wiki.nginx.org/HttpLuaModule#ngx.flush

Best regards,
-agentzh

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

handle NGX_AGAIN properly

Julien Zefi 1170 July 09, 2013 08:14PM

Re: handle NGX_AGAIN properly

Yichun Zhang (agentzh) 615 July 09, 2013 09:04PM

Re: handle NGX_AGAIN properly

Julien Zefi 660 July 13, 2013 08:22PM

Re: handle NGX_AGAIN properly

Yichun Zhang (agentzh) 565 July 14, 2013 02:42AM

Re: handle NGX_AGAIN properly Attachments

Julien Zefi 592 July 14, 2013 11:44PM

Re: handle NGX_AGAIN properly

wandenberg 641 January 03, 2015 07:00PM



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

Online Users

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