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:Manlio Perillo (manl@public.gmane.org)
Date:Oct 23, 2007 3:51:06 am
List:ru.sysoev.nginx

Igor Sysoev ha scritto:

On Tue, Oct 23, 2007 at 11:29:41AM +0200, Manlio Perillo wrote:

Igor Sysoev ha scritto:

[...]

The loop should be:

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

self->r->connection->write->ready = 1;

} while (rc == NGX_AGAIN);

In usual processing event->ready is set by event module (kqueue/epoll/etc).

Ok, this solves the problem, thanks! Now ngx_http_output_filter returns NGX_ERROR when the client closes the connection.

There is only one minor problem. When I send a SIGINT signal to nginx during a blocking write operation, the termination is not "clean":

while (rc == NGX_AGAIN && !ngx_quit && !ngx_terminate);

There is still a problem with a: [crit] 19816#0: *1 writev() failed (14: Bad address), client: 10.0.0.10, server: localhost, URL: "/wsgi-write/", host: "localdomain:1234"

The problem may be caused by the memory buffer (owned by Python) being deallocated when the write function returns and nginx still continues to write the data.

I have "patched" the code with a:

if (ngx_quit || ngx_terminate) { b->pos = 0; b->last = 0; b->last_buf = 0; b->memory = 0; return NULL; }