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));
}
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) {
+ 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)) {
- /* the usual case - prevent the next loop iteration
- * from referencing a brigade which lives in a
- * cleared pool
- */
more = NULL;
}
else {
- /* change the lifetime of "more" to the connection's
- * lifetime
- *
- * XXX a shorter lifetime would be better for long-running
- * keep-alive connections...might be able to use the
- * input brigade's pool
+ /* 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, c->pool);
+ 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,
"core_output_filter: writing data to the network");