File apache2-mod_watchdog-do-not-call-a-watchdog-instance-for.patch of Package apache2.33761

From 27e5fe3770b536cba33d633b0c162755050bb4a1 Mon Sep 17 00:00:00 2001
From: Stefan Eissing <icing@apache.org>
Date: Thu, 24 Feb 2022 13:20:19 +0000
Subject: [PATCH]   *) mod_watchdog: do not call a watchdog instance for     
 AP_WATCHDOG_STATE_STOPPING outside its thread, as      watchdog instances are
 not prepared to be invoked      concurrently.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1898376 13f79535-47bb-0310-9956-ffa450edef68
---
 modules/core/mod_watchdog.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/modules/core/mod_watchdog.c b/modules/core/mod_watchdog.c
index fba5e87ed9..94a72c2416 100644
--- a/modules/core/mod_watchdog.c
+++ b/modules/core/mod_watchdog.c
@@ -72,37 +72,16 @@ static apr_interval_time_t wd_interval = AP_WD_TM_INTERVAL;
 static int mpm_is_forked = AP_MPMQ_NOT_SUPPORTED;
 static const char *wd_proc_mutex_type = "watchdog-callback";
 
-static void wd_worker_stop(ap_watchdog_t *w)
-{
-    /* Do nothing if the thread wasn't started. */
-    if (apr_atomic_read32(&w->thread_started) != 1)
-        return;
-
-    if (apr_atomic_read32(&w->is_running)) {
-        watchdog_list_t *wl = w->callbacks;
-        while (wl) {
-            if (wl->status == APR_SUCCESS) {
-                /* Execute watchdog callback with STOPPING state */
-                (*wl->callback_fn)(AP_WATCHDOG_STATE_STOPPING,
-                                    (void *)wl->data, w->pool);
-                wl->status = APR_EOF;
-            }
-            wl = wl->next;
-        }
-    }
-    apr_atomic_set32(&w->is_running, 0);
-}
-
 static apr_status_t wd_worker_cleanup(void *data)
 {
     apr_status_t rv;
     ap_watchdog_t *w = (ap_watchdog_t *)data;
 
-    /* Do nothing if the thread wasn't started. */
+    /* Do nothing if the thread wasn't started or has terminated. */
     if (apr_atomic_read32(&w->thread_started) != 1)
         return APR_SUCCESS;
 
-    wd_worker_stop(w);
+    apr_atomic_set32(&w->is_running, 0);
     apr_thread_join(&rv, w->thread);
     return rv;
 }
@@ -228,6 +207,7 @@ static void* APR_THREAD_FUNC wd_worker(apr_thread_t *thread, void *data)
         while (wl) {
             if (wl->status == APR_SUCCESS) {
                 /* Execute watchdog callback with STOPPING state */
+                wl->status = APR_EOF;
                 (*wl->callback_fn)(AP_WATCHDOG_STATE_STOPPING,
                                    (void *)wl->data, w->pool);
             }
@@ -590,7 +570,7 @@ static void wd_child_stopping(apr_pool_t *pool, int graceful)
             ap_watchdog_t *w = ap_lookup_provider(AP_WATCHDOG_PGROUP,
                                                   wn[i].provider_name,
                                                   AP_WATCHDOG_CVERSION);
-            wd_worker_stop(w);
+            apr_atomic_set32(&w->is_running, 0);
         }
     }
 }
-- 
2.41.0

openSUSE Build Service is sponsored by