Author: joes Date: Tue Jan 25 16:01:58 2005 New Revision: 126446 URL: http://svn.apache.org/viewcvs?view=rev&rev=126446 Log: Fix the memory leak regression in apreq_env_custom and apreq_env_cgi (created bucket allocators need to be explicitly destroyed).
Modified: httpd/apreq/branches/multi-env-unstable/STATUS httpd/apreq/branches/multi-env-unstable/src/apreq_env_cgi.c httpd/apreq/branches/multi-env-unstable/src/apreq_env_custom.c Modified: httpd/apreq/branches/multi-env-unstable/STATUS Url: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/STATUS?view=diff&rev=126446&p1=httpd/apreq/branches/multi-env-unstable/STATUS&r1=126445&p2=httpd/apreq/branches/multi-env-unstable/STATUS&r2=126446 ============================================================================== --- httpd/apreq/branches/multi-env-unstable/STATUS (original) +++ httpd/apreq/branches/multi-env-unstable/STATUS Tue Jan 25 16:01:58 2005 @@ -20,8 +20,6 @@ RELEASE SHOWSTOPPERS: - The api docs and perl glue are currently broken. - - Need to fix the memory leak regression in apreq_env_custom and - apreq_env_cgi (created bucket allocators need to be explicitly destroyed). CURRENT VOTES: Modified: httpd/apreq/branches/multi-env-unstable/src/apreq_env_cgi.c Url: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/src/apreq_env_cgi.c?view=diff&rev=126446&p1=httpd/apreq/branches/multi-env-unstable/src/apreq_env_cgi.c&r1=126445&p2=httpd/apreq/branches/multi-env-unstable/src/apreq_env_cgi.c&r2=126446 ============================================================================== --- httpd/apreq/branches/multi-env-unstable/src/apreq_env_cgi.c (original) +++ httpd/apreq/branches/multi-env-unstable/src/apreq_env_cgi.c Tue Jan 25 16:01:58 2005 @@ -59,11 +59,23 @@ return cgi_env->pool; } +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(apreq_env_handle_t *env) { struct cgi_env *cgi_env = (struct cgi_env*)env; + apr_bucket_alloc_t *ba = apr_bucket_alloc_create(cgi_env->pool); - return apr_bucket_alloc_create(cgi_env->pool); + apr_pool_cleanup_register(cgi_env->pool, ba, + bucket_alloc_cleanup, + bucket_alloc_cleanup); + return ba; } static const char *cgi_query_string(apreq_env_handle_t *env) Modified: httpd/apreq/branches/multi-env-unstable/src/apreq_env_custom.c Url: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/src/apreq_env_custom.c?view=diff&rev=126446&p1=httpd/apreq/branches/multi-env-unstable/src/apreq_env_custom.c&r1=126445&p2=httpd/apreq/branches/multi-env-unstable/src/apreq_env_custom.c&r2=126446 ============================================================================== --- httpd/apreq/branches/multi-env-unstable/src/apreq_env_custom.c (original) +++ httpd/apreq/branches/multi-env-unstable/src/apreq_env_custom.c Tue Jan 25 16:01:58 2005 @@ -43,11 +43,22 @@ return handle->pool; } +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 *custom_bucket_alloc(apreq_env_handle_t *env) { struct custom_handle *handle = (struct custom_handle*)env; + apr_bucket_alloc_t *ba = apr_bucket_alloc_create(handle->pool); - return apr_bucket_alloc_create(handle->pool); + apr_pool_cleanup_register(handle->pool, ba, + bucket_alloc_cleanup, + bucket_alloc_cleanup); + return ba; } static const char *custom_query_string(apreq_env_handle_t *env)
