]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1883744 from trunk:
authorYann Ylavic <ylavic@apache.org>
Tue, 5 Jan 2021 10:30:09 +0000 (10:30 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 5 Jan 2021 10:30:09 +0000 (10:30 +0000)
mod_proxy: pconf vs pchild consistency, and correctness in ONE_PROCESS mode.

Consistently use pconf for ap_proxy_define_{worker,balancer}() and pchild for
ap_proxu_initialize_{worker,balancer}() in mod_proxy [child_]init code.

pchild is needed in _initialize() for mutexes/shms' child_init and cleanup,
and to avoid a crash on shutdown (i.e. ap_terminate) in ONE_PROCESS mode,
where worker->cp->pool is destroyed twice, let's register conn_pool_cleanup()
as a pre_cleanup of pchild.

Submitted by: ylavic
Reviewed by: ylavic, jorton, covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1885141 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c
modules/proxy/mod_proxy_balancer.c
modules/proxy/proxy_util.c

index 3e30f39dbefdcf84153639cd6a7571f82c4b0ffa..ecd321c89e2b5c6e15e1a7de086bf16c8e2bb96b 100644 (file)
@@ -3018,12 +3018,13 @@ static void child_init(apr_pool_t *p, server_rec *s)
          */
         worker = (proxy_worker *)conf->workers->elts;
         for (i = 0; i < conf->workers->nelts; i++, worker++) {
-            ap_proxy_initialize_worker(worker, s, conf->pool);
+            ap_proxy_initialize_worker(worker, s, p);
         }
         /* Create and initialize forward worker if defined */
         if (conf->req_set && conf->req) {
             proxy_worker *forward;
-            ap_proxy_define_worker(p, &forward, NULL, NULL, "http://www.apache.org", 0);
+            ap_proxy_define_worker(conf->pool, &forward, NULL, NULL,
+                                   "http://www.apache.org", 0);
             conf->forward = forward;
             PROXY_STRNCPY(conf->forward->s->name,     "proxy:forward");
             PROXY_STRNCPY(conf->forward->s->hostname, "*"); /* for compatibility */
@@ -3037,12 +3038,13 @@ static void child_init(apr_pool_t *p, server_rec *s)
             conf->forward->s->status |= PROXY_WORKER_IGNORE_ERRORS;
             /* Mark as the "generic" worker */
             conf->forward->s->status |= PROXY_WORKER_GENERIC;
-            ap_proxy_initialize_worker(conf->forward, s, conf->pool);
+            ap_proxy_initialize_worker(conf->forward, s, p);
             /* Disable address cache for generic forward worker */
             conf->forward->s->is_address_reusable = 0;
         }
         if (!reverse) {
-            ap_proxy_define_worker(p, &reverse, NULL, NULL, "http://www.apache.org", 0);
+            ap_proxy_define_worker(conf->pool, &reverse, NULL, NULL,
+                                   "http://www.apache.org", 0);
             PROXY_STRNCPY(reverse->s->name,     "proxy:reverse");
             PROXY_STRNCPY(reverse->s->hostname, "*"); /* for compatibility */
             PROXY_STRNCPY(reverse->s->hostname_ex, "*");
@@ -3056,7 +3058,7 @@ static void child_init(apr_pool_t *p, server_rec *s)
             /* Mark as the "generic" worker */
             reverse->s->status |= PROXY_WORKER_GENERIC;
             conf->reverse = reverse;
-            ap_proxy_initialize_worker(conf->reverse, s, conf->pool);
+            ap_proxy_initialize_worker(conf->reverse, s, p);
             /* Disable address cache for generic reverse worker */
             reverse->s->is_address_reusable = 0;
         }
index e26e95df062384ac9ed9ee09c8b7af25b2b2c208..f5b0ce1adb24f9acec3846069756bdecf359a165 100644 (file)
@@ -1968,7 +1968,7 @@ static void balancer_child_init(apr_pool_t *p, server_rec *s)
                              balancer->s->name);
                 exit(1); /* Ugly, but what else? */
             }
-            init_balancer_members(conf->pool, s, balancer);
+            init_balancer_members(p, s, balancer);
         }
         s = s->next;
     }
index 18fd93c06f8381811435f0d36b71a13c616acd44..0962ccfc277ac8b8f8325623d12fe02c55eba80e 100644 (file)
@@ -1494,6 +1494,8 @@ static void init_conn_pool(apr_pool_t *p, proxy_worker *worker)
     cp->pool = pool;
     cp->dns_pool = dns_pool;
     worker->cp = cp;
+
+    apr_pool_pre_cleanup_register(p, worker, conn_pool_cleanup);
 }
 
 PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn)
@@ -2108,9 +2110,6 @@ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, ser
                                         connection_constructor, connection_destructor,
                                         worker, worker->cp->pool);
 
-                apr_pool_pre_cleanup_register(worker->cp->pool, worker,
-                                              conn_pool_cleanup);
-
                 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00930)
                     "initialized pool in child %" APR_PID_T_FMT " for (%s) min=%d max=%d smax=%d",
                      getpid(), worker->s->hostname_ex, worker->s->min,