From: Cliff Woolley Date: Fri, 31 May 2002 05:03:09 +0000 (+0000) Subject: fix some major badness: error buckets *cannot* use simple_copy because X-Git-Tag: 2.0.37~146 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebfb28f986f980e36a17ce0ead4c30525db19815;p=apache fix some major badness: error buckets *cannot* use simple_copy because 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 --- diff --git a/include/http_protocol.h b/include/http_protocol.h index 00fbdb5281..17a2d153c8 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -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 */ diff --git a/server/error_bucket.c b/server/error_bucket.c index 5e7303b847..3aa2e9a6e0 100644 --- a/server/error_bucket.c +++ b/server/error_bucket.c @@ -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 };