You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2022/02/24 13:20:19 UTC

svn commit: r1898376 - /httpd/httpd/trunk/modules/core/mod_watchdog.c

Author: icing
Date: Thu Feb 24 13:20:19 2022
New Revision: 1898376

URL: http://svn.apache.org/viewvc?rev=1898376&view=rev
Log:
  *) 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.


Modified:
    httpd/httpd/trunk/modules/core/mod_watchdog.c

Modified: httpd/httpd/trunk/modules/core/mod_watchdog.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/core/mod_watchdog.c?rev=1898376&r1=1898375&r2=1898376&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/core/mod_watchdog.c (original)
+++ httpd/httpd/trunk/modules/core/mod_watchdog.c Thu Feb 24 13:20:19 2022
@@ -72,37 +72,16 @@ static apr_interval_time_t wd_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(a
         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
             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);
         }
     }
 }