httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: ap_save_brigade vs ENOTIMPL setaside
Date Fri, 01 Oct 2004 12:00:16 GMT
On Thu, Sep 23, 2004 at 09:36:30PM +0100, Joe Orton wrote:
> So what's the proper fix?  If ap_save_brigade did:
> 
>  if bkt->setaside() == ENOTIMPL
>    bkt->read()
>    if bkt->setaside() != SUCCESS 
>      give up

There is a problem with this new logic: the mod_perl SV bucket type
happens to be a case where ->setaside() is ENOTIMPL (currently) and
->read() does not morph the bucket type, so then ap_save_brigade() will
abort without doing any work which is quite nasty.

I think the logic needs to be refined to copy the read data into a HEAP
or POOL bucket if the second setaside() call still gives ENOTIMPL, as
below.  I'm not sure whether POOL or HEAP is better, but if it does use
a POOL the data may get copied again if it is later turned into a HEAP,
which seems inefficient.  Comments?

--- server/util_filter.c	26 Sep 2004 15:52:51 -0000	1.101
+++ server/util_filter.c	1 Oct 2004 11:33:27 -0000
@@ -557,6 +557,18 @@
             rv = apr_bucket_read(e, &s, &n, APR_BLOCK_READ);
             if (rv == APR_SUCCESS) {
                 rv = apr_bucket_setaside(e, p);
+                if (rv == APR_ENOTIMPL) {
+                    apr_bucket *h;
+                    
+                    /* No choice but to manually move it into a heap bucket */
+                    h = apr_bucket_heap_create(s, n, NULL, f->c->bucket_alloc);
+                    
+                    APR_BUCKET_INSERT_AFTER(e, h);
+                    apr_bucket_delete(e);
+
+                    rv = APR_SUCCESS;
+                    e = h;
+                }
             }
         }
 




Mime
View raw message