Re: Newbie: Question

Joe Schaefer <[email protected]>
Newsgroups gmane.comp.apache.apreq
Message-ID <[email protected]>
"Edward L. Abrams" <[email protected]> writes:

> 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))
>            {
>              break;
>            }

I don't think we have eos buckets in the upload brigade.

>          else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ) ==
> APR_SUCCESS)
>            {
>              // We have a bucket full of raw data
>              apr_file_write(f, buf, &bytes);
>              filesize += bytes;
>              apr_bucket_delete(b);

I don't like calling APR_BUCKET_NEXT on a deleted bucket.
IMO deleting a bucket is like calling free on it, so it
should be considered a dead pointer at this point.

> 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? 


apreq cleans up its brigades after the request is over.
It shouldn't leak anything comparable to the upload size,
since we use spool (essentially file) buckets to hold that
data.

-- 
Joe Schaefer
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.