Early output by a fastcgi app stops the body sending process

Maxime Bizon mbizon at freebox.fr
Wed May 26 01:01:55 MSD 2010


Hi list,

I'm writing a FastCGI application, in which I do "lazy" POST data
access, meaning stdin is not read until it's needed. That mean that data
can be sent on stdout before stdin is fully read.

But it seems nginx stops writing to stdin (and close the body temp file)
the first time it gets data on stdout:

open("/tmp/nginx/body/0000000007", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE,
0600) = 9
unlink("/tmp/nginx/body/0000000007")    = 0
_llseek(9, 0, [0], SEEK_CUR)            = 0
_llseek(9, 0, [0], SEEK_SET)            = 0
write(9, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"..., 8192) = 8192
_llseek(9, 0, [0], SEEK_SET)            = 0
recv(6, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"..., 8192, 0) = 8192
[...]
connect(10, {sa_family=AF_FILE, path="/tmp/fcgi"}, 110) = 0
getsockopt(10, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
writev(10, [{"\1\1\0\1\0\10\0\0\0\1\0\0\0\0\0\0\1\4\0\1\2^\2\0\f\5QUERY_"..., 648}, {"test=aaaaaaaaaaaaaaaaaaaaaaaaaaa"..., 832}, {"\1\5\0\1\200\0\0\0", 8}], 3) = 1488
sendfile64(10, 9, [0], 32768)           = 32768
writev(10, [{"\1\5\0\1\200\0\0\0", 8}], 1) = 8
sendfile64(10, 9, [32768], 32768)       = 32768
writev(10, [{"\1\5\0\1\200\0\0\0", 8}], 1) = 8
sendfile64(10, 9, [65536], 32768)       = 32768
writev(10, [{"\1\5\0\1\200\0\0\0", 8}], 1) = 8
sendfile64(10, 9, [98304], 32768)       = 20480
epoll_wait(0x8, 0x90558, 0x200, 0xea60) = 2
rt_sigprocmask(SIG_BLOCK, ~[], [], 8)   = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
gettimeofday({1274818417, 182822}, NULL) = 0
recv(6, 0xbee19b17, 1, MSG_PEEK)        = -1 EAGAIN (Resource temporarily unavailable)
recv(10, "\1\6\0\1\0\200\0\0Status: 200\r\nContent-Typ"..., 4096, 0) = 272
close(9)                                = 0
readv(10, 0xbee199fc, 1)                = -1 EAGAIN (Resource temporarily unavailable)


Is it expected ?

from the fastcgi specs:

> The application must wait to finish reading FCGI_PARAMS before it
> begins writing FCGI_STDOUT and FCGI_STDERR, but it needn't finish
> reading from FCGI_STDIN before it begins writing these two streams. 

Thanks,

-- 
Maxime





More information about the nginx-devel mailing list