diff options
| author | Jim Jagielski <jim@apache.org> | 2007-06-13 16:23:19 +0000 |
|---|---|---|
| committer | Jim Jagielski <jim@apache.org> | 2007-06-13 16:23:19 +0000 |
| commit | 91f25252ce2b5311fa76f7c6cd299f745656e0b6 (patch) | |
| tree | 459cad01fd95d9dfe7a260c0e3dbf9df2e5139c6 /server/mpm_common.c | |
| parent | ebf474ed028be5f363f872d23960e4abb1a27225 (diff) | |
| download | httpd-2.2-pid-table.tar.gz | |
Backport of PID table code from trunk to 2.2...httpd-2.2-pid-table
Create a branch for this until we test enough to
fold into 2.2
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/httpd-2.2-pid-table@546948 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/mpm_common.c')
| -rw-r--r-- | server/mpm_common.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/server/mpm_common.c b/server/mpm_common.c index c654cbfb22..a99f6b17ca 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -86,6 +86,41 @@ typedef struct extra_process_t { 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; + apr_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]; + apr_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]; + apr_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)); @@ -113,6 +148,7 @@ int ap_unregister_extra_mpm_process(pid_t pid) extras = cur->next; } free(cur); + ap_unset_pid_table(pid); return 1; /* found */ } else { @@ -127,6 +163,9 @@ static int reclaim_one_pid(pid_t pid, action_t action) 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; |
