Subject: Re: sendfile() behavior while troubleshooting netdevice

From: "J. K. Cliburn" <[email-masked]>
Date: Tue, 29 Jul 2008 08:16:52 -0500

Hi Jarek,

Jarek Poplawski wrote:
> sfclient.c:
> ...
> 		prev = count;
> 		count += ret;
> 		if (prev == count) {
> 			fprintf(stderr, "error: expected %d, received %d\n",
> 				fsize, count);
> --->			exit(1);
> 		}
> 
> Maybe you could try without this exit if anything comes later?

That's the way I initially had it, but I'd get infinite loops when the 
bytes were lost; no additional bytes ever showed up.  The 'if (prev == 
count)' check was added later, just to kick the thing out of that 
infinite loop.

However, your question made me realize that ret can be -1, and I don't 
want to change 'count' in that case.  Changed to

if (ret > 0)
	count += ret;

Thanks,
Jay