[dev] synchronous write

Igor Sysoev is at rambler-co.ru
Tue Oct 23 13:33:14 MSD 2007


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":
> 
>  [notice] 12546#0: using the "epoll" event method
>  [notice] 12546#0: nginx/0.5.31
>  [notice] 12546#0: built by gcc 4.1.2 20061115 (prerelease) (Debian 
> 4.1.1-21)
>  [notice] 12546#0: OS: Linux 2.6.18-5-686
>  [notice] 12546#0: sysctl(KERN_RTSIGMAX): 0
>  [notice] 12546#0: getrlimit(RLIMIT_NOFILE): 1024:1024
>  [notice] 12546#0: start worker processes
>  [notice] 12546#0: start worker process 12548
>  [notice] 12546#0: start worker process 12549
>  [debug] 12548#0: *1 wsgi_handler
>  [debug] 12548#0: *1 mod_wsgi: Loading WSGI script 
> '/usr/local/nginx/nginx-write.py'
>  [debug] 12548#0: *1 mod_wsgi: start_response called
>  [debug] 12548#0: *1 mod_wsgi: sent headers, 0
>  [debug] 12548#0: *1 mod_wsgi: write called 128000000 0
>  [notice] 12549#0: signal 2 (SIGINT) received, exiting
>  [info] 12549#0: epoll_wait() failed (4: Interrupted system call)
>  [notice] 12549#0: exiting
>  [notice] 12548#0: signal 2 (SIGINT) received, exiting
>  [notice] 12546#0: signal 17 (SIGCHLD) received
>  [notice] 12546#0: worker process 12549 exited with code 0
>  [notice] 12546#0: signal 2 (SIGINT) received, exiting
>  [notice] 12546#0: signal 29 (SIGIO) received
>  [notice] 12546#0: signal 14 (SIGALRM) received
>  [notice] 12546#0: signal 14 (SIGALRM) received
>  [notice] 12546#0: signal 14 (SIGALRM) received
>  [notice] 12546#0: signal 14 (SIGALRM) received
>  [notice] 12546#0: signal 17 (SIGCHLD) received
>  [alert] 12546#0: worker process 12548 exited on signal 9
>  [notice] 12546#0: exit
> 
> 
> Not a big problem, however.

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


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list