You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by gr...@apache.org on 2003/01/09 17:27:27 UTC
cvs commit: httpd-2.0/server core.c
gregames 2003/01/09 08:27:26
Modified: server Tag: APACHE_2_0_BRANCH core.c
Log:
prevent fd's from leaking until the end of a long-lived keepalive connection.
Revision Changes Path
No revision
No revision
1.225.2.1 +29 -1 httpd-2.0/server/core.c
Index: core.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/core.c,v
retrieving revision 1.225
retrieving revision 1.225.2.1
diff -u -r1.225 -r1.225.2.1
--- core.c 16 Nov 2002 02:27:33 -0000 1.225
+++ core.c 9 Jan 2003 16:27:25 -0000 1.225.2.1
@@ -3670,6 +3670,7 @@
core_net_rec *net = f->ctx;
core_output_filter_ctx_t *ctx = net->out_ctx;
apr_read_type_e eblock = APR_NONBLOCK_READ;
+ apr_pool_t *input_pool = b->p;
if (ctx == NULL) {
ctx = apr_pcalloc(c->pool, sizeof(*ctx));
@@ -3924,7 +3925,10 @@
}
}
}
- ap_save_brigade(f, &ctx->b, &b, c->pool);
+ if (!ctx->deferred_write_pool) {
+ apr_pool_create(&ctx->deferred_write_pool, c->pool);
+ }
+ ap_save_brigade(f, &ctx->b, &b, ctx->deferred_write_pool);
return APR_SUCCESS;
}
@@ -3995,6 +3999,30 @@
}
apr_brigade_destroy(b);
+
+ /* drive cleanups for resources which were set aside
+ * this may occur before or after termination of the request which
+ * created the resource
+ */
+ if (ctx->deferred_write_pool) {
+ if (more && more->p == ctx->deferred_write_pool) {
+ /* "more" belongs to the deferred_write_pool,
+ * which is about to be cleared.
+ */
+ if (APR_BRIGADE_EMPTY(more)) {
+ more = NULL;
+ }
+ else {
+ /* uh oh... change more's lifetime
+ * to the input brigade's lifetime
+ */
+ apr_bucket_brigade *tmp_more = more;
+ more = NULL;
+ ap_save_brigade(f, &more, &tmp_more, input_pool);
+ }
+ }
+ apr_pool_clear(ctx->deferred_write_pool);
+ }
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_INFO, rv, c->base_server,