lkml.org 
[lkml]   [2001]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [Bench] New benchmark showing fileserver problem in 2.4.12
Date
On Thursday 18 October 2001 04:01, Leo Mauro wrote:
> Small fix to Linus's sample code
>
> unsigned int so_far = 0;
> for (;;) {
> int bytes = read(in, buf+so_far, BUFSIZE-so_far);
> if (bytes <= 0)
> break;
> so_far += bytes;
> if (so_far < BUFSIZE)
> continue;
> write(out, buf, BUFSIZE);
> - so_far = 0;
> + so_far -= BUFSIZE;
> }
> if (so_far)
> write(out, buf, so_far);
>
> to avoid losing data.

You too...

I was close to press the send button but noticed the "BUFSIZE-so_far"
in the read call, just in time(TM).

If it had not been there you would have needed to copy data from the
end of buf (from above BUFSIZE) to the beginning of buf too...
(the required size of buf would have been 2*BUFSIZE)

/RogerL

--
Roger Larsson
Skellefteå
Sweden
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:08    [W:0.092 / U:0.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site