]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
core: Initialize scoreboard's used optional functions on graceful restarts to
authorYann Ylavic <ylavic@apache.org>
Mon, 23 Mar 2015 08:07:18 +0000 (08:07 +0000)
committerYann Ylavic <ylavic@apache.org>
Mon, 23 Mar 2015 08:07:18 +0000 (08:07 +0000)
avoid a crash when relocation occurs.  PR 57177.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1668532 13f79535-47bb-0310-9956-ffa450edef68

server/core.c
server/scoreboard.c

index 7928bbc98dd3423481ea63b6f65a3043147b9387..e3aa970c646be9884e724d3efc9c145ed726fa36 100644 (file)
@@ -5063,6 +5063,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)
 {
     /*
@@ -5242,6 +5247,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
index f6bbe820dd82c7786abd59cad9da6484c2d06911..c7501d9fda1ad6c67975c266c1c21b426716cd5e 100644 (file)
@@ -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,