From 5a653ac440e0aa93cf1a085c5543ec642508020a Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Sun, 30 Oct 2005 22:55:35 +0000 Subject: [PATCH] Moved the extended_status scoreboard update from ap_process_http_connection to the EOR bucket destructor. Also, added some defensive code and comments regarding r->pool lifetime to ap_process_http_connection. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@329664 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_core.c | 26 ++++++++++++++++++-------- server/eor_bucket.c | 4 ++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/modules/http/http_core.c b/modules/http/http_core.c index fad09ef190..be18ec4fca 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -125,11 +125,16 @@ static int ap_process_http_async_connection(conn_rec *c) if (r->status == HTTP_OK) { cs->state = CONN_STATE_HANDLER; ap_process_async_request(r); + /* After the call to ap_process_request, the + * request pool may have been deleted. We set + * r=NULL here to ensure that any dereference + * of r that might be added later in this function + * will result in a segfault immediately instead + * of nondeterministic failures later. + */ + r = NULL; } - if (ap_extended_status) - ap_increment_counts(c->sbh, r); - if (cs->state != CONN_STATE_WRITE_COMPLETION) { /* Something went wrong; close the connection */ cs->state = CONN_STATE_LINGER; @@ -164,15 +169,20 @@ static int ap_process_http_connection(conn_rec *c) if (r->status == HTTP_OK) { cs->state = CONN_STATE_HANDLER; ap_process_request(r); + /* After the call to ap_process_request, the + * request pool will have been deleted. We set + * r=NULL here to ensure that any dereference + * of r that might be added later in this function + * will result in a segfault immediately instead + * of nondeterministic failures later. + */ + r = NULL; } - - if (ap_extended_status) - ap_increment_counts(c->sbh, r); - + if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted) break; - ap_update_child_status(c->sbh, SERVER_BUSY_KEEPALIVE, r); + ap_update_child_status(c->sbh, SERVER_BUSY_KEEPALIVE, NULL); if (ap_graceful_stop_signalled()) break; diff --git a/server/eor_bucket.c b/server/eor_bucket.c index 86230b600d..c7c559e82e 100644 --- a/server/eor_bucket.c +++ b/server/eor_bucket.c @@ -17,6 +17,7 @@ #include "httpd.h" #include "http_request.h" #include "http_protocol.h" +#include "scoreboard.h" static apr_status_t eor_bucket_read(apr_bucket *b, const char **str, apr_size_t *len, apr_read_type_e block) @@ -52,6 +53,9 @@ static void eor_bucket_destroy(void *data) request_rec *r = (request_rec *)data; if (r != NULL) { ap_run_log_transaction(r); + if (ap_extended_status) { + ap_increment_counts(r->connection->sbh, r); + } apr_pool_destroy(r->pool); } } -- 2.40.0