21 messages in ru.sysoev.nginxRe: [dev] synchronous write
FromSent OnAttachments
Manlio PerilloOct 16, 2007 3:32 am 
Igor SysoevOct 16, 2007 11:53 am 
Manlio PerilloOct 16, 2007 12:32 pm 
Igor SysoevOct 16, 2007 12:49 pm 
Manlio PerilloOct 16, 2007 12:56 pm 
Igor SysoevOct 16, 2007 1:00 pm 
Manlio PerilloOct 16, 2007 1:16 pm 
Manlio PerilloOct 21, 2007 2:57 am 
Igor SysoevOct 22, 2007 3:04 am 
Manlio PerilloOct 22, 2007 3:17 am 
Igor SysoevOct 22, 2007 3:39 am 
Manlio PerilloOct 22, 2007 4:10 am 
Igor SysoevOct 22, 2007 4:23 am 
Manlio PerilloOct 22, 2007 4:40 am 
Manlio PerilloOct 22, 2007 12:41 pm 
Manlio PerilloOct 22, 2007 12:48 pm 
Igor SysoevOct 23, 2007 12:10 am 
Igor SysoevOct 23, 2007 12:18 am 
Manlio PerilloOct 23, 2007 2:29 am 
Igor SysoevOct 23, 2007 2:32 am 
Manlio PerilloOct 23, 2007 3:51 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [dev] synchronous writeActions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Oct 23, 2007 12:10:14 am
List:ru.sysoev.nginx

On Mon, Oct 22, 2007 at 09:42:07PM +0200, Manlio Perillo wrote:

Igor Sysoev ha scritto:

On Mon, Oct 22, 2007 at 01:11:21PM +0200, Manlio Perillo wrote:

Igor Sysoev ha scritto:

[...]

No, this completely kill the idea of nginx - a worker will be blocked.

Unfortunately this is required by the WSGI spec, and some "legacy" WSGI applications will block the worker, anyway.

I have implemented an alternative version that uses a buffer, but I would like to know if using this "hack" is "safe", that is if Nginx will send the correct data to the client and if after setting again the socket to nonblocking mode, Nginx will work as usual.

Yes, it will work. However, you should use the following cycle:

ngx_blocking(self->r->connection->fd);

do { rc = ngx_http_output_filter(self->r, &out); } while (rc == NGX_AGAIN);

ngx_nonblocking(self->r->connection->fd);

That's unexpected, I have assumed that with socket in blocking mode ngx_http_output_filter never returns NGX_AGAIN.

No, write() to a socket in blocking mode may send less bytes than you ask.

But NGX_AGAIN is returned also for EINTR?

No, nginx handles EINTR in write/sendfile opertaion and does not return NGX_AGAIN.

I have noted that when testing your "patch" over a slow connection (qemu) and with a very big buffer, hitting Ctrl-C cause an infinite(?) loop.

Could you show debug log of this loop ?

P.S.: even with a very big buffer, ngx_http_output_filter never returns NGX_AGAIN

Probably because kernel TCP buffer is big enough.