From 24fa2034bb373a286bd16912aa10e7404a898ecf Mon Sep 17 00:00:00 2001 From: robs Date: Thu, 28 Feb 2002 15:58:11 +0000 Subject: [PATCH] [WIN32] Add (back) support for use of TerminateProcess() to accomodate applications that do not (properly) support the shutdown event (this feature was introduced in fcgi2 2.2.2 and improved in 2.2.4). The new macro WIN32_SHUTDOWN_GRACEFUL_WAIT in mod_fastcgi.h conrols the interval between signaling a proper shutdown and wacking the process(s) with a TerminateProcess(). --- CHANGES | 7 +++++++ fcgi_pm.c | 34 +++++++++++++++++++++++++++++++++- mod_fastcgi.h | 15 ++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 631fa0e..9f71522 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,12 @@ 2.2.13 + *) [WIN32] Add (back) support for use of TerminateProcess() to accomodate + applications that do not (properly) support the shutdown event (this + feature was introduced in fcgi2 2.2.2 and improved in 2.2.4). The + new macro WIN32_SHUTDOWN_GRACEFUL_WAIT in mod_fastcgi.h conrols the + interval between signaling a proper shutdown and wacking the process(s) + with a TerminateProcess(). + *) [WIN32] Don't set the OVERLAPPED_IO flag on NamedPipe listen HANDLEs - setting it was just plain broken. diff --git a/fcgi_pm.c b/fcgi_pm.c index 3eb0624..e024e9a 100644 --- a/fcgi_pm.c +++ b/fcgi_pm.c @@ -1,5 +1,5 @@ /* - * $Id: fcgi_pm.c,v 1.68 2002/02/23 21:31:19 robs Exp $ + * $Id: fcgi_pm.c,v 1.69 2002/02/28 15:58:11 robs Exp $ */ @@ -135,6 +135,38 @@ static void shutdown_all() s = s->next; } + +#if defined(WIN32) && (WIN32_SHUTDOWN_GRACEFUL_WAIT > 0) + + /* + * WIN32 applications may not have support for the shutdown event + * depending on their application library version + */ + + Sleep(WIN32_SHUTDOWN_GRACEFUL_WAIT); + s = fcgi_servers; + + while (s) + { + ServerProcess *proc = s->procs; + int i; + int numChildren = (s->directive == APP_CLASS_DYNAMIC) + ? dynamicMaxClassProcs + : s->numProcesses; + + /* Send KILL to all processes */ + for (i = 0; i < numChildren; i++, proc++) + { + if (proc->state == FCGI_RUNNING_STATE) + { + fcgi_kill(proc, SIGKILL); + } + } + + s = s->next; + } + +#endif /* WIN32 */ } static int init_listen_sock(fcgi_server * fs) diff --git a/mod_fastcgi.h b/mod_fastcgi.h index d81a5b2..5b16854 100644 --- a/mod_fastcgi.h +++ b/mod_fastcgi.h @@ -1,5 +1,5 @@ /* - * $Id: mod_fastcgi.h,v 1.39 2002/02/04 19:41:56 robs Exp $ + * $Id: mod_fastcgi.h,v 1.40 2002/02/28 15:58:11 robs Exp $ */ #ifndef MOD_FASTCGI_H @@ -20,6 +20,19 @@ */ #define FCGI_NAMED_PIPE_CONNECT_TIMEOUT 90 +/* + * [WIN32] The number of millisecs to wait after having signaled the + * termination event to its applications before issuing a TerminateProcess(). + * If all of the applications are based on a version of the FastCGI + * application library that properly handles the shutdown event + * (fcgi2 v2.2.4), this can be set to <= 0 to prevent the use of + * TerminateProcess() entirely. If non of the applications support the + * termination event, this value can be set to 1. It is highly reccomended + * that the termination event be supported, as TerminateProcess() is a + * brutal way of taking down an application. + */ +#define WIN32_SHUTDOWN_GRACEFUL_WAIT 1000 + #define FCGI_DEFAULT_LISTEN_Q 100 /* listen queue (backlog) depth */ #define FCGI_DEFAULT_RESTART_DELAY 5 /* delay between restarts */ #define DEFAULT_INIT_START_DELAY 1 /* delay between starts */ -- 2.11.4.GIT