apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wilfredo Sánchez Vega <wsanc...@apple.com>
Subject Re: sendfile(2) misbehaves when header iovecs are specified
Date Wed, 14 Nov 2007 21:40:53 GMT
   More from the networking team:

"""
With regard's to Aaron's comments above, the return value is as  
expected.  The "len" parameter specifies the number of bytes for the  
header (if any) and the (possibly partial) contents of the file.  In  
this case, it is 200,000, meaning the entire 80,000 bytes header plus  
120,000 of the file contents, followed by the trailer, which is 90,029  
bytes, will be sent.  The total bytes sent is therefore 290,029 bytes  
(80,000 + 120,000 + 90,029).  It implies that 80,000 bytes of the file  
contents did not get sent; only the first 120,000 bytes did.

So, to elaborate this, on input "len" implies the maximum number of  
bytes in the header and/or file to be sent.  It does not control the  
trailer whatsoever; if a trailer exists, all of it will be sent.  If  
"len" is 0, all of the header and/or file will be sent before the  
trailer (all of it, always) finally gets sent.  On output, "len"  
specifies the total number of bytes sent.

I agree the man page is not clear about this and should be modified.
"""

   This looks to agree with what you are seeing.  Correct?

	-wsv

On Nov 13, 2007, at 5:27 PM, Davi Arnaut wrote:

> Aaron Bannert wrote:
>> Hmm, that's not the behavior I am seeing with Leopard's sendfile. I  
>> am
>> seeing the value-result parameter come back with the total byes in  
>> the
>> file plus the total size of the trailers, excluding the headers.
>>
>> For example, with a header of 80,000 bytes, a file of 200,000 bytes,
>> and a trailer of 90,029 bytes (from APR's test/sendfile.c test). The
>> input to the *len param starts as 200,000 (the size of the file) and
>> after the call it comes back set as 290,029. If you're saying that  
>> the
>> *len return result should be the total bytes sent (headers + file +
>> trailers) then the result should have been 370,049. Note that in this
>> example, the other end of the connection appears to have received at
>> least 119980 bytes.
>>
>>
>> Could we get a detailed explanation of what all the expected inputs
>> and outputs are for sendfile in Leopard() (and if it's different that
>> previous versions, the same for those would help too).
>>
>
> From what I could figure out, it works like this:
>
> o If length <= headers_length: Length output is headers length +
> trailers length. No bytes from the file are sent, headers and trailers
> are sent.
>
> o If length > headers_length, Length output is headers length +  
> trailers
> length + file bytes sent. (length - headers length) bytes from the  
> file
> are sent, headers and trailers are sent.
>
> o If length == 0, Length is headers_length + trailers_length + file
> size. Everything is sent.
>
> Strange...
>
> Regards,
>
> Davi Arnaut


Mime
View raw message