[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#57729: fgets: probably not a bug



On Thu, 10 Feb 2000, Daniel Jacobowitz wrote:
>What do you mean by under high load?  Long lines, in which case it obviously
>will return partial lines?

The server is returning lots of lines that are about 5-10 characters long all
at once.
When the client does a read the STDIO library reads 1K at a time which is
about 200 lines.

>fdopen() creates an unbuffered stream, so the code for fgets does nothing
>more than read from the socket until a newline, EOF, or error is
>encountered.

By necessity the stream it creates is buffered (otherwise it would have to
read a byte at a time to get a line).
I had assumed that if I did one read which returned 200 complete lines and
one half line in the buffer space available, then fgets would try to do
another read on the socket before it returned line 201.  Was my assumption
wrong?


Reply to: