Re: [bug & patch] early connection close with CGI

Nikola Vladov <[email protected]> Sun, 26 Feb 2006 10:16:23 +0200
Newsgroups gmane.comp.web.fnord
Message-ID <[email protected]>
On Sun, Feb 26, 2006 at 03:53:21AM +0100, Laurent Bercot wrote:

It seems OK!  I tried it.  I comment also line 592

	    close(df[1]);
	  }
	}
	// else if (pfd[0].revents&POLLHUP) break;
	else {
cgi_500:  if (startup)
	    badrequest(500,"Internal Server Error","Looks like the CGI crashed.");
	  else {
	    buffer_puts(buffer_1,"\n\n");
	    buffer_puts(buffer_1,"Looks like the CGI crashed.");

Regards, Nikola

>  Under Linux, when you're listening on a pipe with poll(), and
> the writing end of the pipe closes, poll() returns POLLHUP, even
> if some data remains in the kernel buffer. It's unreliable to
> end the event loop when receiving POLLHUP; you have to keep
> reading until read() returns 0.
>  fnord suffers from this problem: when retrieving an image through
> a CGI script, I often get the image truncated.
>  The attached patch corrects the problem. (It doesn't remove the
> offending line, it just comments it out. Felix, do as you please.)