On 4/2/20 11:14 AM, Joe Orton wrote:
> On Thu, Apr 02, 2020 at 10:58:21AM +0200, Yann Ylavic wrote:
>> On Thu, Apr 2, 2020 at 6:39 AM Ruediger Pluem <rpl...@apache.org> wrote:
>>>
>>>> +#define AP_BUCKET_IS_MORPHING(e)    ((e)->length == (apr_size_t)-1)
>>>
>>> Nitpick: After having a second thought on the whole thing, I think the 
>>> above name is misleading to some extend. If MMAP is enabled
>>> a file bucket is also a morphing bucket as a read on it causes the bucket 
>>> to split in an MMAP bucket and a shorter file bucket.
>>> A MMAP bucket consumes at least address space and I vaguely remember cases 
>>> from the past (back in 32 bit times) where filters that
>>> processed (doing apr_bucket_read) a whole brigade at once without passing 
>>> results down the chain on a regular basis caused the
>>> address space to be exhausted by MMAP buckets if the file bucket was huge.
>>
>> How about a less subjective:
>>   #define AP_BUCKET_HAS_LENGTH(e) ((e)->length != (apr_size_t)-1)

!= is bad as we need ==  at least in the cases you mentioned and hence we had 
to do !AP_BUCKET_HAS_LENGTH(e).
Not sure if the compiler optimizes it away. So how about

#define AP_BUCKET_HAS_UNKNOWN_LENGTH(e) ((e)->length == (apr_size_t)-1)

But as said below: It doesn't save characters. It might be easier to read, to 
memorize and less error prone as the cast cannot be
forgotten :-).

>> ?
>>
>> If find it quite painful to type e->length == (apr_size_t)-1, though I
>> could simply use -1 and rely on unsigned promotion..
> 
> Formally this is *determinate* length - all buckets have a length just 
> some of them are indeterminate.
> 
> #define AP_BUCKET_DETERMINATE_LENGTH(e) ((e)->length != (apr_size_t)-1)
>  
> but it is quite a mouthful and exactly the same number of characters as 
> writing it out longhand.  No strong opinion on having a macro for it, 
> probably should be in APR tho ;)
> 

It should be in APR, but that takes quite long until it arrives in httpd. So we 
might create one here and in APR in parallel
and define the AP_ conditionally as the APR_ one if it exists and otherwise on 
our own.

Regards

RĂ¼diger

Reply via email to