From b2b44098eb1e3f4bd9667b560c483e25c41bebd8 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 31 Mar 2015 12:54:40 +0000 Subject: [PATCH] Merge r1668532, r1668535, r1668553 from trunk: core: Initialize scoreboard's used optional functions on graceful restarts to avoid a crash when relocation occurs. PR 57177. core: follow up to r1668532: CHANGES entry. core: follow up to r1668532: always initialize optional_fn pointers in ap_create_scoreboard(). Submitted by: ylavic Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1670325 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ STATUS | 17 ----------------- server/core.c | 7 +++++++ server/scoreboard.c | 10 ++++++---- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/CHANGES b/CHANGES index e2adc759e5..3f997bb956 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,9 @@ Changes with Apache 2.4.13 calls r:wsupgrade() can cause a child process crash. [Edward Lu ] + *) core: Initialize scoreboard's used optional functions on graceful restarts + to avoid a crash when relocation occurs. PR 57177. [Yann Ylavic] + *) mod_dav: Avoid a potential integer underflow in the lock timeout value sent back to a client. The answer to a LOCK request could be an extremly large integer if the time needed to lock the resource was longer that the diff --git a/STATUS b/STATUS index 02369d6005..8476939bd1 100644 --- a/STATUS +++ b/STATUS @@ -106,23 +106,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_proxy_connect/wstunnel: If both client and backend sides get readable - at the same time, don't lose errors occuring while forwarding on the first - side when none occurs next on the other side, and abort. - trunk patch: http://svn.apache.org/r1657636 - http://svn.apache.org/r1657638 - http://svn.apache.org/r1669130 - 2.4.x patch: http://people.apache.org/~ylavic/httpd-2.4.x-mod_proxy-transfer-v3.patch - +1: ylavic, covener, jim - - *) core: Initialize scoreboard's used optional functions on graceful restarts to - avoid a crash when relocation occurs. PR 57177. - trunk patch: http://svn.apache.org/r1668532 - http://svn.apache.org/r1668535 (CHANGES entry) - http://svn.apache.org/r1668553 - 2.4.x patch: trunk works (modulo CHANGES) - +1: ylavic, covener, jim - *) core: If explicitly configured, use the KeepaliveTimeout value of the virtual host which handled the latest request on the connection, or by default the one of the first virtual host bound to the same IP:port. diff --git a/server/core.c b/server/core.c index 749cf5c166..1ef958098c 100644 --- a/server/core.c +++ b/server/core.c @@ -4760,6 +4760,11 @@ static void core_child_init(apr_pool_t *pchild, server_rec *s) apr_random_after_fork(&proc); } +static void core_optional_fn_retrieve(void) +{ + ap_init_scoreboard(NULL); +} + AP_CORE_DECLARE(void) ap_random_parent_after_fork(void) { /* @@ -4939,6 +4944,8 @@ static void register_hooks(apr_pool_t *p) APR_HOOK_REALLY_LAST); ap_hook_dirwalk_stat(core_dirwalk_stat, NULL, NULL, APR_HOOK_REALLY_LAST); ap_hook_open_htaccess(ap_open_htaccess, NULL, NULL, APR_HOOK_REALLY_LAST); + ap_hook_optional_fn_retrieve(core_optional_fn_retrieve, NULL, NULL, + APR_HOOK_MIDDLE); /* register the core's insert_filter hook and register core-provided * filters diff --git a/server/scoreboard.c b/server/scoreboard.c index fa04b91ff4..9e16a2ae5e 100644 --- a/server/scoreboard.c +++ b/server/scoreboard.c @@ -138,8 +138,6 @@ AP_DECLARE(int) ap_calc_scoreboard_size(void) scoreboard_size += sizeof(process_score) * server_limit; scoreboard_size += sizeof(worker_score) * server_limit * thread_limit; - pfn_ap_logio_get_last_bytes = APR_RETRIEVE_OPTIONAL_FN(ap_logio_get_last_bytes); - return scoreboard_size; } @@ -148,6 +146,11 @@ AP_DECLARE(void) ap_init_scoreboard(void *shared_score) char *more_storage; int i; + pfn_ap_logio_get_last_bytes = APR_RETRIEVE_OPTIONAL_FN(ap_logio_get_last_bytes); + if (!shared_score) { + return; + } + ap_calc_scoreboard_size(); ap_scoreboard_image = ap_calloc(1, sizeof(scoreboard) + server_limit * sizeof(worker_score *)); @@ -299,8 +302,6 @@ int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e sb_type) apr_status_t rv; #endif - pfn_ap_logio_get_last_bytes = APR_RETRIEVE_OPTIONAL_FN(ap_logio_get_last_bytes); - if (ap_scoreboard_image) { ap_scoreboard_image->global->restart_time = apr_time_now(); memset(ap_scoreboard_image->parent, 0, @@ -309,6 +310,7 @@ int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e sb_type) memset(ap_scoreboard_image->servers[i], 0, sizeof(worker_score) * thread_limit); } + ap_init_scoreboard(NULL); return OK; } -- 2.50.1