Bug 40893

Summary: apr_brigade_length to return length as is instead of undefined
Product: APR Reporter: Henry Jen <henryjen>
Component: APR-utilAssignee: Apache Portable Runtime bugs mailinglist <bugs>
Status: RESOLVED FIXED    
Severity: enhancement Keywords: PatchAvailable
Priority: P3    
Version: HEAD   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Return available data length

Description Henry Jen 2006-11-03 22:50:35 UTC
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.

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

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.
Comment 1 Henry Jen 2006-11-03 22:51:49 UTC
Created attachment 19087 [details]
Return available data length
Comment 2 Davi Arnaut 2007-07-21 10:43:41 UTC
Slightly different patch committed to trunk in revision 558361:

http://svn.apache.org/viewvc?view=rev&revision=558361