Author: joes Date: Wed Jan 12 19:20:02 2005 New Revision: 125026 URL: http://svn.apache.org/viewcvs?view=rev&rev=125026 Log: Created bucket allocators require explicit destructor calls, otherwise they leak ~ 8K per instance. This bug only impacts the cgi and test environments. For detailed discussion see
http://marc.theaimsgroup.com/?t=110557054800001&r=1&w=2 Modified: httpd/apreq/trunk/src/apreq_env.c Modified: httpd/apreq/trunk/src/apreq_env.c Url: http://svn.apache.org/viewcvs/httpd/apreq/trunk/src/apreq_env.c?view=diff&rev=125026&p1=httpd/apreq/trunk/src/apreq_env.c&r1=125025&p2=httpd/apreq/trunk/src/apreq_env.c&r2=125026 ============================================================================== --- httpd/apreq/trunk/src/apreq_env.c (original) +++ httpd/apreq/trunk/src/apreq_env.c Wed Jan 12 19:20:02 2005 @@ -150,16 +150,27 @@ #define APREQ_MODULE_NAME "CGI" -#define APREQ_MODULE_MAGIC_NUMBER 20041130 +#define APREQ_MODULE_MAGIC_NUMBER 20050112 static apr_pool_t *cgi_pool(void *env) { return (apr_pool_t *)env; } +static apr_status_t bucket_alloc_cleanup(void *data) +{ + apr_bucket_alloc_t *ba = data; + apr_bucket_alloc_destroy(ba); + return APR_SUCCESS; +} + static apr_bucket_alloc_t *cgi_bucket_alloc(void *env) { - return apr_bucket_alloc_create((apr_pool_t *)env); + dP; + apr_bucket_alloc_t *ba = apr_bucket_alloc_create(p); + apr_pool_cleanup_register(p, ba, bucket_alloc_cleanup, + bucket_alloc_cleanup); + return ba; } static const char *cgi_query_string(void *env) @@ -304,7 +315,7 @@ apr_status_t s; if (ctx.in == NULL) { - apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(p); + apr_bucket_alloc_t *alloc = cgi_bucket_alloc(p); apr_bucket *stdin_pipe, *eos = apr_bucket_eos_create(alloc); apr_file_t *in; apr_file_open_stdin(&in, p);
