]> granicus.if.org Git - apache/commitdiff
Add fatal exception hook for use by debug modules. The hook is only
authorJeff Trawick <trawick@apache.org>
Wed, 26 Nov 2003 03:45:34 +0000 (03:45 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 26 Nov 2003 03:45:34 +0000 (03:45 +0000)
available if the --enable-exception-hook configure parm is used.

Sample users at http://httpd.apache.org/~trawick/exception_hook.html

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101899 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
configure.in
include/ap_mpm.h
server/mpm_common.c

diff --git a/CHANGES b/CHANGES
index 2937e9517a192f24cf1a69c1bba51197ca564eea..368597b7cea8aba557bcae95b3ebb4a568610902 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Add fatal exception hook for use by debug modules.  The hook is only
+     available if the --enable-exception-hook configure parm is used.
+     [Jeff Trawick]
+
   *) mod_ssl/mod_status: Re-enable support for output of SSL session
      cache information in server-status page.  [Joe Orton]
 
index e930890fc210d1a1ec6b381c36d71b9db43e9242..1fdffc165b9af51f48fef8e147c623ed6576ddf3 100644 (file)
@@ -365,6 +365,12 @@ if test $v4mapped = "yes" -a $ac_cv_define_APR_HAVE_IPV6 = "yes"; then
               [Allow IPv4 connections on IPv6 listening sockets])
 fi
 
+AC_ARG_ENABLE(exception-hook,APACHE_HELP_STRING(--enable-exception-hook,Enable fatal exception hook),
+[
+    AC_DEFINE(AP_ENABLE_EXCEPTION_HOOK, 1,
+              [Allow modules to run hook after a fatal exception])
+])dnl
+
 AC_ARG_ENABLE(maintainer-mode,APACHE_HELP_STRING(--enable-maintainer-mode,Turn on debugging and compile time warnings),
 [
   APR_ADDTO(CPPFLAGS, -DAP_DEBUG)
index 5896cbe97613f4cb4a4c299646f39de2d6378ba4..691f8124c1032b14efe65509625593f4c44f711c 100644 (file)
@@ -197,4 +197,13 @@ extern void moncontrol(int);
 #define AP_MONCONTROL(x)
 #endif
 
+#if AP_ENABLE_EXCEPTION_HOOK
+typedef struct ap_exception_info_t {
+    int sig;
+    pid_t pid;
+} ap_exception_info_t;
+
+AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei))
+#endif /*AP_ENABLE_EXCEPTION_HOOK*/
+
 #endif
index 51ba206e7775146edc6e02b32752990637fad579..efaceaa7394fb1b2237b1c63f11b4a6ad2fe8401 100644 (file)
@@ -919,11 +919,35 @@ const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,
 static pid_t parent_pid, my_pid;
 apr_pool_t *pconf;
 
+#if AP_ENABLE_EXCEPTION_HOOK
+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};
+
+    if (geteuid() != 0 && 
+        my_pid != parent_pid) {
+        ei.sig = sig;
+        ei.pid = my_pid;
+        ap_run_fatal_exception(&ei);
+    }
+}
+#endif /* AP_ENABLE_EXCEPTION_HOOK */
+
 /* handle all varieties of core dumping signals */
 static void sig_coredump(int sig)
 {
     apr_filepath_set(ap_coredump_dir, pconf);
     apr_signal(sig, SIG_DFL);
+#if AP_ENABLE_EXCEPTION_HOOK
+    run_fatal_exception_hook(sig);
+#endif
     if (my_pid == parent_pid) {
         ap_log_error(APLOG_MARK, APLOG_NOTICE,
                      0, ap_server_conf,