[dev] synchronous write

Manlio Perillo manlio_perillo at libero.it
Mon Oct 22 14:17:33 MSD 2007


Igor Sysoev ha scritto:
> [...]
>
>> Igor, do you thing that setting temporarily the socket to blocking mode 
>> can be a solution?
>>
>>     out.buf = b;
>>     out.next = NULL;
>>
>>     b->pos = data;
>>     b->last = data + len;
>>
>>     b->memory = 1;
>>     b->flush = 1;
>>
>>     ngx_blocking(self->r->connection->fd);
>>     rc = ngx_http_output_filter(self->r, &out);
>>     ngx_nonblocking(self->r->connection->fd);
>>
>>
>> I have done some tests and it seems to work.
> 
> 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.



Thanks  Manlio Perillo





More information about the nginx mailing list