Welcome! Log In Create A New Profile

Advanced

Re: Adding a delay in body filter response

Yichun Zhang (agentzh)
November 29, 2014 12:54AM
Hello!

On Fri, Nov 28, 2014 at 2:46 PM, Tod Baudais wrote:
> I am developing a body filter module that processes html and has to do a
> process in the middle of sending a response that can take upwards of a
> couple seconds.

What is this "process" exactly? Is it CPU-bound computation or just a
(nonblocking) IO operation?

> So for example, the first half of the HTML gets sent
> immediately, a process happens and eventually finishes, then second half
> gets sent (the contents of the second half being dependent on the results of
> the process).

If the "process" is an IO operation, this looks trivial if it is
implemented as a content handler instead of a body filter.

> How to I get a body filter to "wait" for a bit and then
> continue sometime later?

Alas. The nginx output body filter does not provide a "wait" mode by
its design. To make it actually wait, we need to cheat a bit by
exhausting the "busy bufs" of the content handler (so as to make it
stop sending more bufs in non-buffered mode). That's the only way I'm
aware of. (Feel free to prove me wrong.)

And the closest thing in the stock nginx distribution is the
limit_rate mechanism which can serve as an example. But again, this is
complicated, so be careful :)

Regards,
-agentzh

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

Adding a delay in body filter response

Tod Baudais 566 November 28, 2014 05:48PM

Re: Adding a delay in body filter response

Yichun Zhang (agentzh) 285 November 29, 2014 12:54AM



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

Online Users

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