From a39c55dcca5493682c060d232a7cae78087eb526 Mon Sep 17 00:00:00 2001 From: robs Date: Mon, 29 Jul 2002 00:07:28 +0000 Subject: [PATCH] fix forking and call to close a socket --- fcgi_pm.c | 21 ++++++++++++++++----- mod_fastcgi.c | 18 +++++++----------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/fcgi_pm.c b/fcgi_pm.c index 35bdcc7..7adff91 100644 --- a/fcgi_pm.c +++ b/fcgi_pm.c @@ -1,5 +1,5 @@ /* - * $Id: fcgi_pm.c,v 1.74 2002/07/26 03:10:54 robs Exp $ + * $Id: fcgi_pm.c,v 1.75 2002/07/29 00:07:28 robs Exp $ */ @@ -71,6 +71,7 @@ static void fcgi_kill(ServerProcess *process, int sig) process->state = FCGI_VICTIM_STATE; #ifdef WIN32 + if (sig == SIGTERM) { SetEvent(process->terminationEvent); @@ -83,19 +84,26 @@ static void fcgi_kill(ServerProcess *process, int sig) { ap_assert(0); } -#else + +#else /* !WIN32 */ + +#ifndef APACHE2 if (fcgi_wrapper) { seteuid_root(); } +#endif kill(process->pid, sig); +#ifndef APACHE2 if (fcgi_wrapper) { seteuid_user(); } #endif + +#endif /* !WIN32 */ } /******************************************************************************* @@ -1569,10 +1577,13 @@ void fcgi_pm_main(void *dummy) fcgi_config_set_env_var(fcgi_config_pool, dynamicEnvp, &i, "SystemRoot"); #else + +#ifndef APACHE2 reduce_privileges(); + change_process_name("fcgi-pm"); +#endif close(fcgi_pm_pipe[1]); - change_process_name("fcgi-pm"); setup_signals(); if (fcgi_wrapper) { @@ -1887,7 +1898,7 @@ ChildFound: ap_log_error(FCGI_LOG_WARN_NOERRNO, fcgi_apache_main_server, "FastCGI:%s server \"%s\" (pid %ld) terminated due to uncaught signal '%d' (%s)%s", (s->directive == APP_CLASS_DYNAMIC) ? " (dynamic)" : "", - s->fs_path, (long) childPid, WTERMSIG(waitStatus), SYS_SIGLIST[WTERMSIG(waitStatus)], + s->fs_path, (long) childPid, WTERMSIG(waitStatus), get_signal_text(waitStatus), #ifdef WCOREDUMP WCOREDUMP(waitStatus) ? ", a core file may have been generated" : ""); #else @@ -1898,7 +1909,7 @@ ChildFound: ap_log_error(FCGI_LOG_WARN_NOERRNO, fcgi_apache_main_server, "FastCGI:%s server \"%s\" (pid %ld) stopped due to uncaught signal '%d' (%s)", (s->directive == APP_CLASS_DYNAMIC) ? " (dynamic)" : "", - s->fs_path, (long) childPid, WTERMSIG(waitStatus), SYS_SIGLIST[WTERMSIG(waitStatus)]); + s->fs_path, (long) childPid, WTERMSIG(waitStatus), get_signal_text(waitStatus)); } } /* for (;;), waitpid() */ diff --git a/mod_fastcgi.c b/mod_fastcgi.c index 26515f7..9be0cde 100644 --- a/mod_fastcgi.c +++ b/mod_fastcgi.c @@ -3,7 +3,7 @@ * * Apache server module for FastCGI. * - * $Id: mod_fastcgi.c,v 1.135 2002/07/26 03:10:54 robs Exp $ + * $Id: mod_fastcgi.c,v 1.136 2002/07/29 00:07:28 robs Exp $ * * Copyright (c) 1995-1996 Open Market, Inc. * @@ -301,21 +301,17 @@ static apcb_t init_module(server_rec *s, pool *p) apr_status_t rv; rv = apr_proc_fork(proc, tp); - if (rv) - return rv; - if (proc->pid == 0) + if (rv == APR_INCHILD) { /* child */ - - close(fcgi_pm_pipe[1]); - dup2(fcgi_pm_pipe[0], 0); - close(fcgi_pm_pipe[0]); - fcgi_pm_main(NULL); - exit(1); } + else if (rv != APR_INPARENT) + { + return rv; + } /* parent */ @@ -949,7 +945,7 @@ static void close_connection_to_fs(fcgi_request *fr) set_nonblocking(fr, FALSE); /* abort the connection entirely */ setsockopt(fr->fd, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)); - closesocket(fr->fd); + close(fr->fd); fr->fd = -1; #endif /* ! WIN32 */ -- 2.11.4.GIT