apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henry Jen <henry...@ztune.net>
Subject Re: apr_brigade_length to return length as is instead of undefined
Date Fri, 29 Sep 2006 23:51:52 GMT
Garrett Rooney wrote:
> On 9/23/06, Henry Jen <henryjen@ztune.net> wrote:
>> Hi,
>> apr_brigade_length with readall set to 1 will try to read from a bucket
>> with length -1 to determine the value.
>> Currently, if apr_bucket_read with the bucket of length -1 returns other
>> than APR_SUCCESS, the length returned is undefined.
>> In case of a socket bucket with a nonblocking socket, the return status
>> could be EAGAIN and the length is still useful to determine value
>> available at the moment. A use case, for example, is waiting for a
>> certain amount of data to be available.
>> I would propose to return the value up-to-date is better than undefined.
>> The application can decide whether the value is meaningful with the
>> returned status. Does this make sense?
>> Attached is a simple path specifying the length.
> Is total going to be the correct value in that case?  I know in
> apr_file_read you can get stuff in *len even if an error has occurred,
> can that occur with apr_bucket_read?  If so, it seems like you'd want
> *length = total + *len, or something like that.

It may not be accurate, but it is what you can get from the brigade for 

In the socket example, you are not likely to get an length back when 
there is an error. Even you do have a length, the data read was 
discarded so that it won't be in the brigade.

Given that, I think not adding the *len value might be a better solution.


View raw message