You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by gr...@apache.org on 2001/08/10 03:34:11 UTC
cvs commit: httpd-2.0/server/mpm/prefork prefork.c
gregames 01/08/09 18:34:11
Modified: server/mpm/threaded threaded.c
server/mpm/worker worker.c
server/mpm/prefork prefork.c
Log:
record something in the error log if the parent process seg faults
Submitted by: Jeff Trawick
Revision Changes Path
1.57 +14 -1 httpd-2.0/server/mpm/threaded/threaded.c
Index: threaded.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/threaded/threaded.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- threaded.c 2001/08/07 22:28:51 1.56
+++ threaded.c 2001/08/10 01:34:11 1.57
@@ -174,6 +174,7 @@
static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main
thread. Use this instead */
+static pid_t parent_pid;
/* Keep track of the number of worker threads currently active */
static int worker_thread_count;
static apr_lock_t *worker_thread_count_mutex;
@@ -247,6 +248,18 @@
{
chdir(ap_coredump_dir);
apr_signal(sig, SIG_DFL);
+ if (ap_my_pid == parent_pid) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+ 0, ap_server_conf,
+ "seg fault or similar nasty error detected "
+ "in the parent process");
+
+ /* XXX we can probably add some rudimentary cleanup code here,
+ * like getting rid of the pid file. If any additional bad stuff
+ * happens, we are protected from recursive errors taking down the
+ * system since this function is no longer the signal handler GLA
+ */
+ }
kill(ap_my_pid, sig);
/* At this point we've got sig blocked, because we're still inside
* the signal handler. When we leave the signal handler it will
@@ -1348,7 +1361,7 @@
if (!one_process && !no_detach) {
apr_proc_detach();
}
- ap_my_pid = getpid();
+ parent_pid = ap_my_pid = getpid();
}
unixd_pre_config(ptemp);
1.10 +14 -1 httpd-2.0/server/mpm/worker/worker.c
Index: worker.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- worker.c 2001/08/06 15:55:43 1.9
+++ worker.c 2001/08/10 01:34:11 1.10
@@ -183,6 +183,7 @@
static pid_t ap_my_pid; /* Linux getpid() doesn't work except in main
thread. Use this instead */
+static pid_t parent_pid;
/* Keep track of the number of worker threads currently active */
static int worker_thread_count;
static apr_lock_t *worker_thread_count_mutex;
@@ -262,6 +263,18 @@
{
chdir(ap_coredump_dir);
apr_signal(sig, SIG_DFL);
+ if (ap_my_pid == parent_pid) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+ 0, ap_server_conf,
+ "seg fault or similar nasty error detected "
+ "in the parent process");
+
+ /* XXX we can probably add some rudimentary cleanup code here,
+ * like getting rid of the pid file. If any additional bad stuff
+ * happens, we are protected from recursive errors taking down the
+ * system since this function is no longer the signal handler GLA
+ */
+ }
kill(ap_my_pid, sig);
/* At this point we've got sig blocked, because we're still inside
* the signal handler. When we leave the signal handler it will
@@ -1403,7 +1416,7 @@
if (!one_process && !no_detach) {
apr_proc_detach();
}
- ap_my_pid = getpid();
+ parent_pid = ap_my_pid = getpid();
}
unixd_pre_config(ptemp);
1.193 +8 -1 httpd-2.0/server/mpm/prefork/prefork.c
Index: prefork.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -r1.192 -r1.193
--- prefork.c 2001/07/18 20:45:35 1.192
+++ prefork.c 2001/08/10 01:34:11 1.193
@@ -179,6 +179,7 @@
static apr_pool_t *pchild; /* Pool for httpd child stuff */
static pid_t ap_my_pid; /* it seems silly to call getpid all the time */
+static pid_t parent_pid;
#ifndef MULTITHREAD
static int my_child_num;
#endif
@@ -383,6 +384,12 @@
{
chdir(ap_coredump_dir);
apr_signal(sig, SIG_DFL);
+ if (ap_my_pid == parent_pid) {
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
+ 0, ap_server_conf,
+ "seg fault or similar nasty error detected "
+ "in the parent process");
+ }
kill(getpid(), sig);
/* At this point we've got sig blocked, because we're still inside
* the signal handler. When we leave the signal handler it will
@@ -1314,7 +1321,7 @@
apr_proc_detach();
}
- ap_my_pid = getpid();
+ parent_pid = ap_my_pid = getpid();
}
unixd_pre_config(ptemp);