httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Edward L. Abrams" <>
Subject Re: Newbie: Question
Date Wed, 28 Jun 2006 01:36:27 GMT
Thank you very much.  Is the following too loose:

      for (b = APR_BRIGADE_FIRST(bb);
           b != APR_BRIGADE_SENTINEL(bb);
           b = APR_BUCKET_NEXT(b))
          if (APR_BUCKET_IS_EOS(b))
          else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ) == 
              // We have a bucket full of raw data
              apr_file_write(f, buf, &bytes);
              filesize += bytes;

      if (bb != NULL)

Also, a last question: when dealing with file buckets, I understand that 
heap buckets are created as the file is read.  That closely corresponds 
with what you say below.  So my question is: does this mean there is 
more cleanup that has to be done wrt the brigade file->upload, the file 
bucket brigade?  Sometimes it seems to me like the code above leaks too 
-- that may be because of the difference between it and your suggestion 
(which I don't really see a significant difference) or because of 
something having specifically to do with cleaning up after filebody.

Anyway, thank you!


Joe Schaefer wrote:
> "Edward L. Abrams" <> writes:
>>   // dump the values in this brigade:
>>   for (b = APR_BRIGADE_FIRST(bb);
>>        b != APR_BRIGADE_SENTINEL(bb);
>>        b = APR_BUCKET_NEXT(b))
> This is the source of your leak.
> What you need to do is copy the upload brigade
> and iterate over it using something like
>     while (!APR_BRIGADE_EMPTY(bb)) {
>        apr_bucket_t *e = APR_BRIGADE_FIRST(bb);
> from the bucket, do something with data...
>        apr_bucket_delete(e);
>     }
> ie, destroy the buckets as you read from them.
> reading from file buckets tends to convert those buckets
> into heap buckets, and unless you delete them as you go,
> you wind up copying the entire spool file into RAM.

View raw message