httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <n...@webthing.com>
Subject Re: Watchdog code for Apache
Date Mon, 06 Jun 2005 22:45:37 GMT
Jeff Trawick wrote:
> On 6/4/05, Nick Kew <nick@webthing.com> wrote:
> 
>>It also seems better for the watchdog code to run in Apache's
>>master process than to fork off a separate process.
> 
> ...
> 
>>My current thinking is to use ap_wait_or_timeout and:
> 
> 
> create a hook that runs there

Agreed.  I've made a patch for that: it works in place of my previous
watchdog code, and offers a better solution.  Any objections to
my committing it?

--- include/mpm_common.h        2005-04-12 21:39:50.649851544 +0100
+++ include/mpm_common.h.new    2005-06-06 23:41:46.778013008 +0100
@@ -296,6 +296,8 @@
                                              const char *arg);
 #endif

+AP_DECLARE_HOOK(int,watchdog,(apr_pool_t *p))
+
 #ifdef __cplusplus
 }
 #endif


--- server/mpm_common.c 2005-04-12 21:39:40.682366832 +0100
+++ server/mpm_common.c.new     2005-06-06 23:42:58.649086944 +0100
@@ -59,6 +59,21 @@
 #include <unistd.h>
 #endif

+APR_HOOK_STRUCT(
+#if AP_ENABLE_EXCEPTION_HOOK
+    APR_HOOK_LINK(fatal_exception)
+#endif
+    APR_HOOK_LINK(watchdog)
+)
+
+#if AP_ENABLE_EXCEPTION_HOOK
+AP_IMPLEMENT_HOOK_RUN_ALL(int, fatal_exception,
+                          (ap_exception_info_t *ei), (ei), OK, DECLINED)
+#endif
+AP_IMPLEMENT_HOOK_RUN_ALL(int, watchdog,
+                          (apr_pool_t *p), (p), OK, DECLINED)
+
+
 #ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES

 typedef enum {DO_NOTHING, SEND_SIGTERM, SEND_SIGKILL, GIVEUP} action_t;
@@ -275,6 +290,7 @@
     ++wait_or_timeout_counter;
     if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
         wait_or_timeout_counter = 0;
+        ap_run_watchdog(p);
     }

     rv = apr_proc_wait_all_procs(ret, exitcode, status, APR_NOWAIT, p);
@@ -1028,13 +1044,6 @@
     return NULL;
 }

-APR_HOOK_STRUCT(
-    APR_HOOK_LINK(fatal_exception)
-)
-
-AP_IMPLEMENT_HOOK_RUN_ALL(int, fatal_exception,
-                          (ap_exception_info_t *ei), (ei), OK, DECLINED)
-
 static void run_fatal_exception_hook(int sig)
 {
     ap_exception_info_t ei = {0};


> 
> maybe mpms implement an optional function that a module could call to
> do process management work?
> 
> even when the MPM doesn't implement that function, it is still useful
> to have a module identify stuck requests

That's the next step:-)

-- 
Nick Kew


Mime
View raw message