CGI-Output truncated - what does POLLHUP mean?

Simon Budig <[email protected]> Fri, 28 Mar 2008 20:46:01 +0100
Newsgroups gmane.comp.web.fnord
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all.

I today discovered, that sometimes fnord seems to truncate the output
from a CGI without the CGI showing any sign of misbehaviour.

After digging a bit into it (unfortunately the fnord release as shipped
by blackfin-uclinux, but the same code shows up in fnord-1.10) I found
this piece of code in start_cgi(), at the end of the
if (pfd[0].revents&POLLIN)-block (line 567 in fnord-1.10):

   if (pfd[0].revents&POLLHUP) break;

which aborts reading into the buffer.

I was wondering about the reasoning behind that. I am by no means an
expert on pipes and poll, but this looks fishy to me. POLLHUP seems to
indicate, that the opposite end has closed its side of the pipe. And if
that is the case fnord gives up. I have the impression that sometimes
some data is left in a buffer of the pipe though (this even might be
uclinux specific, no idea actually), which then gets implicitely
discarded by fnord.

After removing the line mentioned above I no longer see that happening.
I just wonder - is this the correct fix? I'm too hazy about the
semantics of POLLHUP and it seems to have been put there on purpose...  :)

Thanks,
        Simon
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH7Ur5O2O/RXesiHARAnlqAJ99kNdGmOlnYF2gjZZ1qg09rRuyOQCguyqc
kpf4fXqCpqwAkFTdRcGPsZk=
=XfD7
-----END PGP SIGNATURE-----