From f9f4c470a85d8d2ef78a5f993f8f27728dea2830 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Tue, 23 May 2000 21:04:03 +0000 Subject: [PATCH] Convert ap_proc_t to a complete type. This lets us access the pid directly. Only the prefork MPM has been ported so far, the rest of the Unix MPM's are coming later today. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85279 13f79535-47bb-0310-9956-ffa450edef68 --- modules/filters/mod_include.c | 6 +++--- modules/generators/mod_cgi.c | 10 +++++----- server/log.c | 12 ++++++------ server/mpm/prefork/prefork.c | 21 +++++++-------------- server/mpm_common.c | 4 ++-- 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index b70c21fde9..adc298d66d 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -822,7 +822,7 @@ static int include_cmd(char *s, request_rec *r) include_cmd_arg arg; BUFF *script_in; ap_procattr_t *procattr; - ap_proc_t *procnew; + ap_proc_t procnew; ap_status_t rc; ap_table_t *env = r->subprocess_env; char **argv; @@ -880,9 +880,9 @@ static int include_cmd(char *s, request_rec *r) "couldn't create child process: %d: %s", rc, s); } else { - ap_note_subprocess(r->pool, procnew, kill_after_timeout); + ap_note_subprocess(r->pool, &procnew, kill_after_timeout); /* Fill in BUFF structure for parents pipe to child's stdout */ - ap_get_childout(&file, procnew); + file = procnew.stdout; iol = ap_create_file_iol(file); if (!iol) return APR_EBADF; diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 2ff36d36e8..8bc39979b4 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -295,7 +295,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr { char **env; ap_procattr_t *procattr; - ap_proc_t *procnew; + ap_proc_t procnew; ap_status_t rc = APR_SUCCESS; ap_file_t *file = NULL; ap_iol *iol; @@ -349,10 +349,10 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr "couldn't create child process: %d: %s", rc, r->filename); } else { - ap_note_subprocess(p, procnew, kill_after_timeout); + ap_note_subprocess(p, &procnew, kill_after_timeout); /* Fill in BUFF structure for parents pipe to child's stdout */ - ap_get_childout(&file, procnew); + file = procnew.stdout; iol = ap_create_file_iol(file); if (!iol) return APR_EBADF; @@ -361,7 +361,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr ap_bsetopt(*script_in, BO_TIMEOUT, &r->server->timeout); /* Fill in BUFF structure for parents pipe to child's stdin */ - ap_get_childin(&file, procnew); + file = procnew.stdin; iol = ap_create_file_iol(file); if (!iol) return APR_EBADF; @@ -370,7 +370,7 @@ static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **scr ap_bsetopt(*script_out, BO_TIMEOUT, &r->server->timeout); /* Fill in BUFF structure for parents pipe to child's stderr */ - ap_get_childerr(&file, procnew); + file = procnew.stderr; iol = ap_create_file_iol(file); if (!iol) return APR_EBADF; diff --git a/server/log.c b/server/log.c index d63bcc5efe..89d52981b9 100644 --- a/server/log.c +++ b/server/log.c @@ -168,7 +168,7 @@ static int log_child(ap_pool_t *p, const char *progname, */ int rc = -1; ap_procattr_t *procattr; - ap_proc_t *procnew; + ap_proc_t procnew; #ifdef SIGHUP /* No concept of a child process on Win32 */ @@ -192,8 +192,8 @@ static int log_child(ap_pool_t *p, const char *progname, rc = ap_create_process(&procnew, pname, args, NULL, procattr, p); if (rc == APR_SUCCESS) { - ap_note_subprocess(p, procnew, kill_after_timeout); - ap_get_childin(fpin, procnew); + ap_note_subprocess(p, &procnew, kill_after_timeout); + (*fpin) = procnew.stdin; } } @@ -589,7 +589,7 @@ static int piped_log_spawn(piped_log *pl) { int rc; ap_procattr_t *procattr; - ap_proc_t *procnew; + ap_proc_t procnew; #ifdef SIGHUP ap_signal(SIGHUP, SIG_IGN); @@ -617,8 +617,8 @@ static int piped_log_spawn(piped_log *pl) /* I am assuming that if ap_create_process was */ /* successful that the child is running. */ RAISE_SIGSTOP(PIPED_LOG_SPAWN); - pl->pid = procnew; - ap_register_other_child(procnew, piped_log_maintenance, pl, + pl->pid = &procnew; + ap_register_other_child(&procnew, piped_log_maintenance, pl, ap_piped_log_write_fd(pl), pl->p); } } diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index ec38b3dedd..3da49bf355 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -1019,11 +1019,9 @@ static void increment_counts(int child_num, request_rec *r) static int find_child_by_pid(ap_proc_t *pid) { int i; - int actual_pid; - ap_get_os_proc(&actual_pid, pid); for (i = 0; i < ap_max_daemons_limit; ++i) - if (ap_scoreboard_image->parent[i].pid == actual_pid) + if (ap_scoreboard_image->parent[i].pid == pid->pid) return i; return -1; @@ -1798,10 +1796,8 @@ static void perform_idle_server_maintenance(void) } -static void process_child_status(ap_proc_t *abs_pid, ap_wait_t status) +static void process_child_status(ap_proc_t *pid, ap_wait_t status) { - int pid; - ap_get_os_proc(&pid, abs_pid); /* Child died... if it died due to a fatal error, * we should simply bail out. */ @@ -1810,7 +1806,7 @@ static void process_child_status(ap_proc_t *abs_pid, ap_wait_t status) ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, ap_server_conf, "Child %d returned a Fatal error... \n" "Apache is exiting!", - pid); + pid->pid); exit(APEXIT_CHILDFATAL); } if (WIFSIGNALED(status)) { @@ -1828,7 +1824,7 @@ static void process_child_status(ap_proc_t *abs_pid, ap_wait_t status) 0, ap_server_conf, "child pid %d exit signal %s (%d), " "possible coredump in %s", - pid, (WTERMSIG(status) >= NumSIG) ? "" : + pid->pid, (WTERMSIG(status) >= NumSIG) ? "" : SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status), ap_coredump_dir); } @@ -1836,7 +1832,7 @@ static void process_child_status(ap_proc_t *abs_pid, ap_wait_t status) #endif ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, ap_server_conf, - "child pid %d exit signal %s (%d)", pid, + "child pid %d exit signal %s (%d)", pid->pid, SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status)); #ifdef WCOREDUMP } @@ -1845,7 +1841,7 @@ static void process_child_status(ap_proc_t *abs_pid, ap_wait_t status) ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, ap_server_conf, "child pid %d exit signal %d", - pid, WTERMSIG(status)); + pid->pid, WTERMSIG(status)); #endif } } @@ -1994,12 +1990,9 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) * scoreboard. Somehow we don't know about this * child. */ - ap_os_proc_t os_pid; - - ap_get_os_proc(&os_pid, pid); ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, ap_server_conf, - "long lost child came home! (pid %d)", os_pid); + "long lost child came home! (pid %d)", pid->pid); } /* Don't perform idle maintenance when a child dies, * only do it when there's a timeout. Remember only a diff --git a/server/mpm_common.c b/server/mpm_common.c index b4efc03585..cba30a701f 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -180,7 +180,7 @@ ap_proc_t *ap_wait_or_timeout(ap_wait_t *status, ap_pool_t *p) { struct timeval tv; ap_status_t rv; - ap_proc_t *ret = NULL; + ap_proc_t *ret; ++wait_or_timeout_counter; if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { @@ -189,7 +189,7 @@ ap_proc_t *ap_wait_or_timeout(ap_wait_t *status, ap_pool_t *p) ap_probe_writable_fds(); #endif } - rv = ap_wait_all_procs(&ret, status, APR_NOWAIT, p); + rv = ap_wait_all_procs(ret, status, APR_NOWAIT, p); if (ap_canonical_error(rv) == APR_EINTR) { return NULL; } -- 2.50.1