Nginx Module (I/O block)

Maxim Dounin mdounin at mdounin.ru
Sat Feb 9 23:25:04 UTC 2013


Hello!

On Sat, Feb 09, 2013 at 04:41:54PM +0100, alexander_koch_log wrote:

> It is not clear to me how to avoid blocking the nginx reactor loop
> when creating an nginx module which should perform some long I/O
> operations  and return the response to the client. Or is this
> handled internally by Nginx?

Correct aproach is to avoid blocking for a long time, and use 
non-blocking I/O and event-based notification instead.

What exactly should (and can) be done depends on the exact case.  
E.g. to work with sockets there are lots of various functions 
available to simplify things.  Working with files without blocking 
is harder and not always possible, but a common case is handled by 
nginx - to send some large file you just have to open the file and 
ask nginx to send an in-file buffer.

-- 
Maxim Dounin
http://nginx.com/support.html



More information about the nginx-devel mailing list