lkml.org 
[lkml]   [2001]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Bench] New benchmark showing fileserver problem in 2.4.12
On Wed, 17 Oct 2001, 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.

Checking the return from write() for errors might be a nice idea too,
otherwise you carry on reading, and trying to append, even if the target
device is full (or whatever).


James.
--
"Our attitude with TCP/IP is, `Hey, we'll do it, but don't make a big
system, because we can't fix it if it breaks -- nobody can.'"

"TCP/IP is OK if you've got a little informal club, and it doesn't make
any difference if it takes a while to fix it."
-- Ken Olson, in Digital News, 1988

-
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.052 / U:3.584 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site