Must really be safe_read(),not full_read()? (was: [PATCH] fix httpd lockup in cgi POSTs)

Paul Albrecht albrecht at rdi1.com
Tue Feb 13 13:58:50 UTC 2007


On Mon, 2007-02-12 at 23:28 +0100, Denis Vlasenko wrote:
> On Monday 12 February 2007 22:33, Paul Albrecht wrote:
> > > So far I am happy with "bbox httpd doesn't support insane cgis
> > > which split their HTTP response" way.
> > > 
> > 
> > A cgi program doesn't have to "split" its output for the problem to
> > occur because the data is read over a socket over a network and is not
> > buffered. There's simply no guarantee an unbuffered read gets a full
> > line of output from a cgi program however the data gets output.
> 
> No, data is written thru the local pipe from cgi to httpd process.

Yes, of course, the cgi program and busybox httpd server communicate
over a pipe, not a tcp socket.

However, I still think that because the read syscall is unbuffered you
can't assume that if you write x bytes to one end of the pipe you're
guaranteed x bytes on the *first* read on the other end of the pipe.

I think you're supposed to check the number of bytes read and continue
doing reads until you get as much data as you're expecting or get end of
file.

Finally, whether you accept this explanation or not it's a fact that the
simple cgi program I posted in my previous message fails intermittently.



More information about the busybox mailing list