From 080cca7c2a17034cdcb9b874bf80502d3444fae8 Mon Sep 17 00:00:00 2001 From: robs Date: Thu, 3 May 2001 20:51:24 +0000 Subject: [PATCH] Close the old pipe file descriptor in apache main on USR1/HUP (elimnates a small leak). James E. Jurach Jr. jjurach@fundsxpress.com --- CHANGES | 3 +++ fcgi_config.c | 14 +++++++++++++- mod_fastcgi.c | 22 +++++++++++++--------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index d0e3eb4..0a51176 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ 2.2.11 + *) Close the old pipe file descriptor in apache main on USR1/HUP + (elimnates a small leak). James E. Jurach Jr. jjurach@fundsxpress.com + *) Fix a bug in fcgi_config_set_authoritative_slot(). Tetsuya Furukawa [tetsuya@secom-sis.co.jp] diff --git a/fcgi_config.c b/fcgi_config.c index 1283654..6becdbb 100644 --- a/fcgi_config.c +++ b/fcgi_config.c @@ -1,5 +1,5 @@ /* - * $Id: fcgi_config.c,v 1.27 2001/03/29 19:11:07 robs Exp $ + * $Id: fcgi_config.c,v 1.28 2001/05/03 20:51:24 robs Exp $ */ #include "fcgi.h" @@ -263,6 +263,18 @@ void fcgi_config_reset_globals(void* dummy) dynamicRestartDelay = FCGI_DEFAULT_RESTART_DELAY; dynamic_pass_headers = NULL; dynamic_idle_timeout = FCGI_DEFAULT_IDLE_TIMEOUT; + +#ifndef WIN32 + /* Close any old pipe (HUP/USR1) */ + if (fcgi_pm_pipe[0] != -1) { + close(fcgi_pm_pipe[0]); + fcgi_pm_pipe[0] = -1; + } + if (fcgi_pm_pipe[1] != -1) { + close(fcgi_pm_pipe[1]); + fcgi_pm_pipe[1] = -1; + } +#endif } /******************************************************************************* diff --git a/mod_fastcgi.c b/mod_fastcgi.c index c4c78ea..caf1eca 100644 --- a/mod_fastcgi.c +++ b/mod_fastcgi.c @@ -3,7 +3,7 @@ * * Apache server module for FastCGI. * - * $Id: mod_fastcgi.c,v 1.109 2001/03/27 14:07:53 robs Exp $ + * $Id: mod_fastcgi.c,v 1.110 2001/05/03 20:51:24 robs Exp $ * * Copyright (c) 1995-1996 Open Market, Inc. * @@ -98,17 +98,21 @@ fcgi_server *fcgi_servers = NULL; /* AppClasses */ char *fcgi_socket_dir = DEFAULT_SOCK_DIR; /* default FastCgiIpcDir */ -int fcgi_pm_pipe[2]; -pid_t fcgi_pm_pid = -1; - char *fcgi_dynamic_dir = NULL; /* directory for the dynamic * fastcgi apps' sockets */ #ifdef WIN32 + #pragma warning( disable : 4706 4100 4127) fcgi_pm_job *fcgi_dynamic_mbox = NULL; HANDLE *fcgi_dynamic_mbox_mutex = NULL; HANDLE fcgi_pm_thread = INVALID_HANDLE_VALUE; + +#else + +int fcgi_pm_pipe[2] = { -1, -1 }; +pid_t fcgi_pm_pid = -1; + #endif char *fcgi_empty_env = NULL; @@ -257,11 +261,6 @@ static void init_module(server_rec *s, pool *p) ap_log_error(FCGI_LOG_ERR, s, "FastCGI: %s", err); #ifndef WIN32 - /* Create the pipe for comm with the PM */ - if (pipe(fcgi_pm_pipe) < 0) { - ap_log_error(FCGI_LOG_ERR, s, "FastCGI: pipe() failed"); - } - /* Spawn the PM only once. Under Unix, Apache calls init() routines * twice, once before detach() and once after. Win32 doesn't detach. * Under DSO, DSO modules are unloaded between the two init() calls. @@ -271,6 +270,11 @@ static void init_module(server_rec *s, pool *p) if (ap_standalone && getppid() != 1) return; + /* Create the pipe for comm with the PM */ + if (pipe(fcgi_pm_pipe) < 0) { + ap_log_error(FCGI_LOG_ERR, s, "FastCGI: pipe() failed"); + } + /* Start the Process Manager */ fcgi_pm_pid = ap_spawn_child(p, fcgi_pm_main, NULL, kill_only_once, NULL, NULL, NULL); if (fcgi_pm_pid <= 0) { -- 2.11.4.GIT