You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mt...@apache.org on 2009/03/28 18:41:10 UTC

svn commit: r759518 - /httpd/httpd/trunk/modules/mappers/mod_watchdog.c

Author: mturk
Date: Sat Mar 28 17:41:09 2009
New Revision: 759518

URL: http://svn.apache.org/viewvc?rev=759518&view=rev
Log:
Query the mpm state and clear the running flag if mpm is stopping.

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

Modified: httpd/httpd/trunk/modules/mappers/mod_watchdog.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_watchdog.c?rev=759518&r1=759517&r2=759518&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_watchdog.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_watchdog.c Sat Mar 28 17:41:09 2009
@@ -95,6 +95,7 @@
     int locked = 0;
     int probed = 0;
     int inited = 0;
+    int mpmq_s = 0;
 
     w->pool = apr_thread_pool_get(thread);
     w->is_running = 1;
@@ -102,6 +103,14 @@
     apr_thread_mutex_unlock(w->startup);
     if (w->mutex) {
         while (w->is_running) {
+            if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpmq_s) != APR_SUCCESS) {
+                w->is_running = 0;
+                break;
+            }
+            if (mpmq_s == AP_MPMQ_STOPPING) {
+                w->is_running = 0;
+                break;
+            }
             rv = apr_proc_mutex_trylock(w->mutex);
             if (rv == APR_SUCCESS) {
                 if (probed) {
@@ -115,6 +124,14 @@
                     while (w->is_running && probed > 0) {
                         apr_sleep(AP_WD_TM_INTERVAL);
                         probed--;
+                        if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpmq_s) != APR_SUCCESS) {
+                            w->is_running = 0;
+                            break;
+                        }
+                        if (mpmq_s == AP_MPMQ_STOPPING) {
+                            w->is_running = 0;
+                            break;
+                        }
                     }
                 }
                 locked = 1;
@@ -155,6 +172,12 @@
         watchdog_list_t *wl = w->callbacks;
 
         apr_sleep(AP_WD_TM_SLICE);
+        if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpmq_s) != APR_SUCCESS) {
+            w->is_running = 0;
+        }
+        if (mpmq_s == AP_MPMQ_STOPPING) {
+            w->is_running = 0;
+        }
         if (!w->is_running) {
             break;
         }
@@ -169,6 +192,12 @@
                     /* Execute watchdog callback */
                     wl->status = (*wl->callback_fn)(AP_WATCHDOG_STATE_RUNNING,
                                                     (void *)wl->data, ctx);
+                    if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpmq_s) != APR_SUCCESS) {
+                        w->is_running = 0;
+                    }
+                    if (mpmq_s == AP_MPMQ_STOPPING) {
+                        w->is_running = 0;
+                    }
                 }
             }
             wl = wl->next;
@@ -211,10 +240,10 @@
             wl = wl->next;
         }
     }
-        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, wd_server_conf->s,
-                     "%sWatchdog (%s) stopping (%" APR_PID_T_FMT ")",
-                     w->singleton ? "Singleton" : "",
-                     w->name, getpid());
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, wd_server_conf->s,
+                 "%sWatchdog (%s) stopping (%" APR_PID_T_FMT ")",
+                 w->singleton ? "Singleton" : "",
+                 w->name, getpid());
 
     if (locked)
         apr_proc_mutex_unlock(w->mutex);