On 9/10/21 4:04 PM, Yann Ylavic wrote:
> Index: buckets/apr_buckets_file.c
> ===================================================================
> --- buckets/apr_buckets_file.c        (revision 1893196)
> +++ buckets/apr_buckets_file.c        (working copy)

> @@ -223,11 +223,33 @@ APR_DECLARE(apr_status_t) apr_bucket_file_set_buf_
>          return APR_SUCCESS;
>      }
>  
> -    if (!apr_pool_is_ancestor(a->readpool, reqpool)) {
> -        a->readpool = reqpool;
> +    /* If the file is shared/split accross multiple buckets, this bucket 
> can't
> +     * take exclusive ownership with apr_file_setaside() (thus invalidating 
> the
> +     * current/old a->fd), let's apr_file_dup() in this case instead.
> +     */
> +    if (a->refcount.refcount > 1) {
> +        apr_bucket_file *new;
> +        apr_status_t rv;
> +
> +        rv = apr_file_dup(&fd, f, reqpool);
> +        if (rv != APR_SUCCESS) {
> +            return rv;
> +        }
> +
> +        new = apr_bucket_alloc(sizeof(*new), b->list);
> +        memcpy(new, a, sizeof(*new));
> +        new->refcount.refcount = 1;
> +        new->readpool = reqpool;

Why is the above no longer conditional on apr_pool_is_ancestor(a->readpool, 
reqpool) like in the else branch?

> +
> +        a->refcount.refcount--;
> +        a = b->data = new;
>      }
> -
> -    apr_file_setaside(&fd, f, reqpool);
> +    else {
> +        apr_file_setaside(&fd, f, reqpool);
> +        if (!apr_pool_is_ancestor(a->readpool, reqpool)) {
> +            a->readpool = reqpool;
> +        }
> +    }
>      a->fd = fd;
>      return APR_SUCCESS;
>  }


Regards

RĂ¼diger

Reply via email to