]> granicus.if.org Git - apache/commitdiff
fix some major badness: error buckets *cannot* use simple_copy because
authorCliff Woolley <jwoolley@apache.org>
Fri, 31 May 2002 05:03:09 +0000 (05:03 +0000)
committerCliff Woolley <jwoolley@apache.org>
Fri, 31 May 2002 05:03:09 +0000 (05:03 +0000)
they're not simple buckets.  they have a private data structure which
gets freed.  if you're going to copy them and share whatever ->data points
to (which is what simple_copy does), you have to refcount the structure,
which is the whole point of apr_bucket_refcount and apr_bucket_shared_copy.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95421 13f79535-47bb-0310-9956-ffa450edef68

include/http_protocol.h
server/error_bucket.c

index 00fbdb528105a3a670c1695e30b1609f1c0ab14e..17a2d153c842274883401c48daa21ff730b6414a 100644 (file)
@@ -658,6 +658,8 @@ typedef struct ap_bucket_error ap_bucket_error;
  * first brigade to be sent from a given filter.
  */
 struct ap_bucket_error {
+    /** Number of buckets using this memory */
+    apr_bucket_refcount refcount;
     /** The error code */
     int status;
     /** The error string */
index 5e7303b8473af56275239f5c7d5e040640220777..3aa2e9a6e08e22be15a2e3fec54721e008fccde6 100644 (file)
@@ -67,6 +67,15 @@ static apr_status_t error_bucket_read(apr_bucket *b, const char **str,
     return APR_SUCCESS;
 }
 
+static void error_bucket_destroy(void *data)
+{
+    ap_bucket_error *h = data;
+
+    if (apr_bucket_shared_destroy(h)) {
+        apr_bucket_free(h);
+    }
+}
+
 AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
                                               const char *buf, apr_pool_t *p)
 {
@@ -76,10 +85,8 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
     h->status = error;
     h->data = (buf) ? apr_pstrdup(p, buf) : NULL;
 
-    b->length = 0;
-    b->start  = 0;
+    b = apr_bucket_shared_make(b, h, 0, 0);
     b->type = &ap_bucket_type_error;
-    b->data = h;
     return b;
 }
 
@@ -97,9 +104,9 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
 
 AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_error = {
     "ERROR", 5,
-    apr_bucket_free,
+    error_bucket_destroy,
     error_bucket_read,
     apr_bucket_setaside_notimpl,
     apr_bucket_split_notimpl,
-    apr_bucket_simple_copy
+    apr_bucket_shared_copy
 };