Re: CGI-Output truncated - what does POLLHUP mean?
Simon Budig <[email protected]> Thu, 10 Apr 2008 00:16:48 +0200
| Newsgroups | gmane.comp.web.fnord |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Felix von Leitner wrote:
>> if (pfd[0].revents&POLLHUP) break;
>> which aborts reading into the buffer.
[...]
> I have never experienced CGI truncation with fnord. Can you please try
> it on a regular Linux and see if you can reproduce it there?
>
> In general, we should also be able to treat POLLHUP like POLLIN, and
> then read returns an error.
Sorry for not replying earlier, I got distracted by tons of other weird
stuff...
I unfortunately have not been able to try to reproduce this with a
regular Linux, since the CGI in question is pretty specific to the
embedded hardware, I guess that there is a patch in Debian at least
hints that it has happened to someone else. I have now applied a
slightly modified version of the Debian Patch (which basically seems to
do what you suggested) and it seems to work OK.
There is another slight problem: there is no error checking on the
buffer_put() (which returns the error code of the underlying syscall
from the buffer implementation). Which is a problem when you're
streaming content (potentially forever) and the client stops reading the
stuff - there is a useless CGI process hanging around forever and
writing stuff to fnord, which happily wastes cycles writing it to an
invalid file descriptor...
We now do this at line 564:
if (buffer_put(buffer_1,ibuf,n) < 0) {
break;
}
and it helps.
And in case someone else wants to implement CGI's streaming multimedia
content: do an "alarm(0)" as the first thing in your CGI if you wonder
why your CGI stops streaming after five minutes :)
Bye,
Simon
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFH/UBQO2O/RXesiHARAjBBAJ0XakFdXWM399UzLRVL2CeHOHGgqgCfdBI2
kmTO/wU/zCcIAveoh9OMzQI=
=fULT
-----END PGP SIGNATURE-----