]> granicus.if.org Git - apache/commitdiff
Defensive
authorJim Jagielski <jim@apache.org>
Tue, 7 Mar 2017 19:10:19 +0000 (19:10 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 7 Mar 2017 19:10:19 +0000 (19:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1785871 13f79535-47bb-0310-9956-ffa450edef68

docs/log-message-tags/next-number
modules/proxy/mod_proxy_hcheck.c

index e7ea1abc3cc916a8e775d7cd7f61521f40f45d51..8a0934b514a47ecaba382db654ee89559df42216 100644 (file)
@@ -1 +1 @@
-10019
+10020
index 04563986bee6e6b1efe249e9ed7fd926d3beb1a9..af31d909754ccdf71a94e69c7653261aa6489dd9 100644 (file)
@@ -981,11 +981,13 @@ static int hc_post_config(apr_pool_t *p, apr_pool_t *plog,
                        apr_pool_t *ptemp, server_rec *s)
 {
     apr_status_t rv;
-    sctx_t *ctx;
 
     APR_OPTIONAL_FN_TYPE(ap_watchdog_get_instance) *hc_watchdog_get_instance;
     APR_OPTIONAL_FN_TYPE(ap_watchdog_register_callback) *hc_watchdog_register_callback;
 
+    if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) {
+        return OK;
+    }
     hc_watchdog_get_instance = APR_RETRIEVE_OPTIONAL_FN(ap_watchdog_get_instance);
     hc_watchdog_register_callback = APR_RETRIEVE_OPTIONAL_FN(ap_watchdog_register_callback);
     if (!hc_watchdog_get_instance || !hc_watchdog_register_callback) {
@@ -1003,9 +1005,16 @@ static int hc_post_config(apr_pool_t *p, apr_pool_t *plog,
         return !OK;
     }
     while (s) {
-        ctx = (sctx_t *) ap_get_module_config(s->module_config,
-                                              &proxy_hcheck_module);
-
+        sctx_t *ctx = ap_get_module_config(s->module_config,
+                                           &proxy_hcheck_module);
+
+        if (s != ctx->s) {
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(10019)
+                         "We somehow have a context/server mismatch (%pp:%pp)",
+                         s, ctx->s);
+            s = s->next;
+            continue;
+        }
         rv = hc_watchdog_register_callback(watchdog,
                 apr_time_from_sec(HCHECK_WATHCHDOG_INTERVAL),
                 ctx,