httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r543583 - in /httpd/httpd/branches/httpd-pid-table: ./ include/ server/ server/mpm/beos/ server/mpm/experimental/event/ server/mpm/experimental/leader/ server/mpm/experimental/perchild/ server/mpm/experimental/threadpool/ server/mpm/netware...
Date Fri, 01 Jun 2007 19:28:32 GMT
Author: jim
Date: Fri Jun  1 12:28:31 2007
New Revision: 543583

URL: http://svn.apache.org/viewvc?view=rev&rev=543583
Log:
Create work-in-progress branch

Added:
    httpd/httpd/branches/httpd-pid-table/
      - copied from r543523, httpd/httpd/trunk/
Modified:
    httpd/httpd/branches/httpd-pid-table/include/mpm_common.h
    httpd/httpd/branches/httpd-pid-table/server/main.c
    httpd/httpd/branches/httpd-pid-table/server/mpm/beos/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/event.c
    httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/leader/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/perchild/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/threadpool/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/netware/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/prefork.c
    httpd/httpd/branches/httpd-pid-table/server/mpm/worker/mpm.h
    httpd/httpd/branches/httpd-pid-table/server/mpm/worker/worker.c
    httpd/httpd/branches/httpd-pid-table/server/mpm_common.c
    httpd/httpd/branches/httpd-pid-table/server/scoreboard.c

Modified: httpd/httpd/branches/httpd-pid-table/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/include/mpm_common.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/include/mpm_common.h (original)
+++ httpd/httpd/branches/httpd-pid-table/include/mpm_common.h Fri Jun  1 12:28:31 2007
@@ -349,6 +349,14 @@
                                              const char *arg);
 #endif
 
+/*
+ * The parent process pid table
+ */
+extern apr_table_t *ap_pid_table;
+int ap_in_pid_table(pid_t pid);
+void ap_set_pid_table(pid_t pid);
+void ap_unset_pid_table(pid_t pid);
+
 AP_DECLARE_HOOK(int,monitor,(apr_pool_t *p))
 
 #ifdef __cplusplus

Modified: httpd/httpd/branches/httpd-pid-table/server/main.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/main.c?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/main.c (original)
+++ httpd/httpd/branches/httpd-pid-table/server/main.c Fri Jun  1 12:28:31 2007
@@ -480,6 +480,7 @@
     ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
     ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
     ap_server_config_defines   = apr_array_make(pcommands, 1, sizeof(char *));
+    ap_pid_table               = apr_table_make(pglobal, 1024);
 
     error = ap_setup_prelinked_modules(process);
     if (error) {

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/beos/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/beos/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/beos/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/beos/mpm.h Fri Jun  1 12:28:31 2007
@@ -31,7 +31,10 @@
 
 #define MPM_NAME "Beos"
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->servers[0][i].tid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 
 #define AP_MPM_WANT_RECLAIM_CHILD_PROCESSES
 #define AP_MPM_WANT_WAIT_OR_TIMEOUT

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/event.c?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/event.c (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/event.c Fri Jun  1
12:28:31 2007
@@ -1643,6 +1643,7 @@
     /* else */
     ap_scoreboard_image->parent[slot].quiescing = 0;
     ap_scoreboard_image->parent[slot].pid = pid;
+    ap_set_pid_table(pid);
     return 0;
 }
 
@@ -2062,10 +2063,13 @@
             active_children = 0;
             for (index = 0; index < ap_daemons_limit; ++index) {
                 if (MPM_CHILD_PID(index) != 0) {
-                    if (kill(MPM_CHILD_PID(index), 0) == 0) {
+                    if (ap_in_pid_table(MPM_CHILD_PID(index))) {
+                        if (kill(MPM_CHILD_PID(index), 0) == 0) {
                             active_children = 1;
+                            ap_unset_pid_table(MPM_CHILD_PID(index));
                             /* Having just one child is enough to stay around */
                             break;
+                        }
                     }
                 }
             }

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/event/mpm.h Fri Jun  1 12:28:31
2007
@@ -50,7 +50,10 @@
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 #define MPM_ACCEPT_FUNC unixd_accept
 
 extern int ap_threads_per_child;

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/leader/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/leader/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/leader/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/leader/mpm.h Fri Jun  1 12:28:31
2007
@@ -50,7 +50,10 @@
 
 #define AP_MPM_USES_POD 1
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 #define MPM_ACCEPT_FUNC unixd_accept
 
 extern int ap_threads_per_child;

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/perchild/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/perchild/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/perchild/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/perchild/mpm.h Fri Jun  1
12:28:31 2007
@@ -49,7 +49,10 @@
 #define AP_MPM_USES_POD
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 #define MPM_ACCEPT_FUNC unixd_accept
 
 /* Table of child status */

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/threadpool/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/threadpool/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/threadpool/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/experimental/threadpool/mpm.h Fri Jun
 1 12:28:31 2007
@@ -49,7 +49,10 @@
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 #define MPM_ACCEPT_FUNC unixd_accept
 
 extern int ap_threads_per_child;

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/netware/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/netware/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/netware/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/netware/mpm.h Fri Jun  1 12:28:31 2007
@@ -48,7 +48,10 @@
 */
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 
 extern int ap_threads_per_child;
 extern int ap_max_workers_limit;

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/mpm.h Fri Jun  1 12:28:31 2007
@@ -52,7 +52,10 @@
 
 #define AP_MPM_USES_POD 1
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 #define MPM_ACCEPT_FUNC unixd_accept
 
 extern int ap_threads_per_child;

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/prefork.c?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/prefork/prefork.c Fri Jun  1 12:28:31
2007
@@ -305,13 +305,18 @@
     int n, pid;
 
     for (n = 0; n < ap_max_daemons_limit; ++n) {
-        if (ap_scoreboard_image->servers[n][0].status != SERVER_DEAD &&
-                kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) {
-            ap_update_child_status_from_indexes(n, 0, SERVER_DEAD, NULL);
-            /* just mark it as having a successful exit status */
-            *status = APR_PROC_EXIT;
-            *exitcode = 0;
-            return(pid);
+        pid = ap_scoreboard_image->parent[n].pid;
+        if (ap_scoreboard_image->servers[n][0].status != SERVER_DEAD) {
+            if (ap_in_pid_table(pid)) {
+                if (kill(pid, 0) == -1) {
+                    ap_update_child_status_from_indexes(n, 0, SERVER_DEAD, NULL);
+                    /* just mark it as having a successful exit status */
+                    *status = APR_PROC_EXIT;
+                    *exitcode = 0;
+                    ap_unset_pid_table(pid);
+                    return(pid);
+                }
+            }
         }
     }
     return 0;
@@ -737,6 +742,7 @@
     }
 
     ap_scoreboard_image->parent[slot].pid = pid;
+    ap_set_pid_table(pid);
 
     return 0;
 }
@@ -1119,8 +1125,10 @@
         for (index = 0; index < ap_daemons_limit; ++index) {
             if (ap_scoreboard_image->servers[index][0].status != SERVER_DEAD) {
                 /* Ask each child to close its listeners. */
-                kill(MPM_CHILD_PID(index), AP_SIG_GRACEFUL);
-                active_children++;
+                if (ap_in_pid_table(MPM_CHILD_PID(index))) {
+                    kill(MPM_CHILD_PID(index), AP_SIG_GRACEFUL);
+                    active_children++;
+                }
             }
         }
 
@@ -1158,10 +1166,12 @@
             active_children = 0;
             for (index = 0; index < ap_daemons_limit; ++index) {
                 if (MPM_CHILD_PID(index) != 0) {
-                    if (kill(MPM_CHILD_PID(index), 0) == 0) {
+                    if (ap_in_pid_table(MPM_CHILD_PID(index))) {
+                        if (kill(MPM_CHILD_PID(index), 0) == 0) {
                             active_children = 1;
                             /* Having just one child is enough to stay around */
                             break;
+                        }
                     }
                 }
             }
@@ -1214,7 +1224,9 @@
                  * piped loggers, etc. They almost certainly won't handle
                  * it gracefully.
                  */
-                kill(ap_scoreboard_image->parent[index].pid, AP_SIG_GRACEFUL);
+                if (ap_in_pid_table(MPM_CHILD_PID(index))) {
+                    kill(MPM_CHILD_PID(index), AP_SIG_GRACEFUL);
+                }
             }
         }
     }

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/worker/mpm.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/worker/mpm.h?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/worker/mpm.h (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/worker/mpm.h Fri Jun  1 12:28:31 2007
@@ -50,7 +50,10 @@
 #define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK
 
 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid)
-#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0)
+#define MPM_NOTE_CHILD_KILLED(i) do {         \
+        ap_unset_pid_table(MPM_CHILD_PID(i)); \
+        MPM_CHILD_PID(i) = 0;                 \
+    } while(0) 
 #define MPM_ACCEPT_FUNC unixd_accept
 
 extern int ap_threads_per_child;

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm/worker/worker.c?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm/worker/worker.c (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm/worker/worker.c Fri Jun  1 12:28:31 2007
@@ -1360,6 +1360,8 @@
     }
     ap_scoreboard_image->parent[slot].quiescing = 0;
     ap_scoreboard_image->parent[slot].pid = pid;
+    ap_set_pid_table(pid);
+
     return 0;
 }
 
@@ -1600,6 +1602,7 @@
                                                         (request_rec *) NULL);
 
                 ap_scoreboard_image->parent[child_slot].pid = 0;
+                ap_unset_pid_table(pid);
                 ap_scoreboard_image->parent[child_slot].quiescing = 0;
                 if (processed_status == APEXIT_CHILDSICK) {
                     /* resource shortage, minimize the fork rate */
@@ -1816,10 +1819,12 @@
             active_children = 0;
             for (index = 0; index < ap_daemons_limit; ++index) {
                 if (MPM_CHILD_PID(index) != 0) {
-                    if (kill(MPM_CHILD_PID(index), 0) == 0) {
+                    if (ap_in_pid_table(MPM_CHILD_PID(index))) {
+                        if (kill(MPM_CHILD_PID(index), 0) == 0) {
                             active_children = 1;
                             /* Having just one child is enough to stay around */
                             break;
+                        }
                     }
                 }
             }

Modified: httpd/httpd/branches/httpd-pid-table/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/mpm_common.c?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/mpm_common.c (original)
+++ httpd/httpd/branches/httpd-pid-table/server/mpm_common.c Fri Jun  1 12:28:31 2007
@@ -87,6 +87,41 @@
 
 static extra_process_t *extras;
 
+/*
+ * Parent process local storage of child pids
+ */
+apr_table_t *ap_pid_table;
+
+/*
+ * Check the pid table to see if the actual pid exists
+ */
+int ap_in_pid_table(pid_t pid) {
+    char apid[64];
+    const char *spid;
+    snprintf(apid, sizeof(apid), "%" APR_PID_T_FMT, pid);
+    spid = apr_table_get(ap_pid_table, apid);
+    if (spid && spid[0] == '1' && spid[1] == '\0')
+        return 1;
+    else {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf,
+                     "child process %" APR_PID_T_FMT
+                     " does not exist in local pid table", pid);
+        return 0;
+    }
+}
+
+void ap_set_pid_table(pid_t pid) {
+    char apid[64];
+    snprintf(apid, sizeof(apid), "%" APR_PID_T_FMT, pid);
+    apr_table_set(ap_pid_table, apid, "1");
+}
+
+void ap_unset_pid_table(pid_t pid) {
+    char apid[64];
+    snprintf(apid, sizeof(apid), "%" APR_PID_T_FMT, pid);
+    apr_table_unset(ap_pid_table, apid);
+}
+
 void ap_register_extra_mpm_process(pid_t pid)
 {
     extra_process_t *p = (extra_process_t *)malloc(sizeof(extra_process_t));
@@ -128,6 +163,9 @@
     apr_status_t waitret;
 
     proc.pid = pid;
+    if (!ap_in_pid_table(pid)) {
+        return 0;
+    }
     waitret = apr_proc_wait(&proc, NULL, NULL, APR_NOWAIT);
     if (waitret != APR_CHILD_NOTDONE) {
         return 1;

Modified: httpd/httpd/branches/httpd-pid-table/server/scoreboard.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-pid-table/server/scoreboard.c?view=diff&rev=543583&r1=543523&r2=543583
==============================================================================
--- httpd/httpd/branches/httpd-pid-table/server/scoreboard.c (original)
+++ httpd/httpd/branches/httpd-pid-table/server/scoreboard.c Fri Jun  1 12:28:31 2007
@@ -35,6 +35,7 @@
 #include "ap_mpm.h"
 
 #include "mpm.h"
+#include "mpm_common.h"
 #include "scoreboard.h"
 
 AP_DECLARE_DATA scoreboard *ap_scoreboard_image = NULL;
@@ -363,7 +364,8 @@
     ap_mpm_query(AP_MPMQ_MAX_DAEMONS, &max_daemons_limit);
 
     for (i = 0; i < max_daemons_limit; ++i) {
-        if (ap_scoreboard_image->parent[i].pid == pid->pid) {
+        if (ap_scoreboard_image->parent[i].pid == pid->pid &&
+            ap_in_pid_table(pid->pid)) {
             return i;
         }
     }



Mime
View raw message