From 23d52e138643c29a5a508dcaba047a8f482d690d Mon Sep 17 00:00:00 2001 From: robs Date: Wed, 7 Jan 2004 01:56:00 +0000 Subject: [PATCH] Add a -min-server-life option to the FastCgiConfig and FastCgiServer directives to provide better control of the restart backoff feature. Benjamin Osheroff [ben@gimbo.net] Modified Files: fcgi_config.c fcgi_pm.c fcgi_util.c mod_fastcgi.c fcgi.h mod_fastcgi.h CHANGES docs/mod_fastcgi.html --- CHANGES | 6 ++++++ fcgi.h | 6 +++++- fcgi_config.c | 11 ++++++++++- fcgi_pm.c | 17 +++++++++++------ fcgi_util.c | 3 ++- mod_fastcgi.c | 3 ++- mod_fastcgi.h | 12 ++++-------- 7 files changed, 40 insertions(+), 18 deletions(-) diff --git a/CHANGES b/CHANGES index 8d8eedb..8986c73 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +2.4.3 + + *) Add a -min-server-life option to the FastCgiConfig and + FastCgiServer directives to provide better control of the + restart backoff feature. Benjamin Osheroff [ben@gimbo.net] + 2.4.2 *) [WIN] Fix handle leaks in the process manager. diff --git a/fcgi.h b/fcgi.h index 1cce9e5..aa23e20 100644 --- a/fcgi.h +++ b/fcgi.h @@ -1,5 +1,5 @@ /* - * $Id: fcgi.h,v 1.44 2003/02/03 23:07:37 robs Exp $ + * $Id: fcgi.h,v 1.45 2004/01/07 01:56:00 robs Exp $ */ #ifndef FCGI_H @@ -181,6 +181,8 @@ typedef struct _FastCgiServerInfo { * starting of AppClass processes at init */ u_int restartDelay; /* number of seconds to wait between * restarts after failure. Can be zero. */ + u_int minServerLife; /* minimum number of seconds a server must + * live before it's considered borked. */ int restartOnExit; /* = TRUE = restart. else terminate/free */ u_int numFailures; /* num restarts due to exit failure */ int bad; /* is [not] having start problems */ @@ -582,8 +584,10 @@ extern u_int dynamicInitStartDelay; extern u_int dynamicRestartDelay; extern array_header *dynamic_pass_headers; extern u_int dynamic_idle_timeout; +extern int dynamicMinServerLife; extern int dynamicFlush; + extern module MODULE_VAR_EXPORT fastcgi_module; #endif /* FCGI_H */ diff --git a/fcgi_config.c b/fcgi_config.c index 4591478..2010e69 100644 --- a/fcgi_config.c +++ b/fcgi_config.c @@ -1,5 +1,5 @@ /* - * $Id: fcgi_config.c,v 1.49 2003/10/30 01:08:34 robs Exp $ + * $Id: fcgi_config.c,v 1.50 2004/01/07 01:56:00 robs Exp $ */ #define CORE_PRIVATE @@ -287,6 +287,7 @@ apcb_t fcgi_config_reset_globals(void* dummy) dynamicListenQueueDepth = FCGI_DEFAULT_LISTEN_Q; dynamicInitStartDelay = DEFAULT_INIT_START_DELAY; dynamicRestartDelay = FCGI_DEFAULT_RESTART_DELAY; + dynamicMinServerLife = FCGI_DEFAULT_MIN_SERVER_LIFE; dynamic_pass_headers = NULL; dynamic_idle_timeout = FCGI_DEFAULT_IDLE_TIMEOUT; dynamicFlush = FCGI_FLUSH; @@ -692,6 +693,10 @@ const char *fcgi_config_new_static_server(cmd_parms *cmd, void *dummy, const cha if ((err = get_int(tp, &arg, &s->initStartDelay, 0))) return invalid_value(tp, name, fs_path, option, err); } + else if (strcasecmp(option, "-min-server-life") == 0) { + if ((err = get_int(tp, &arg, &s->minServerLife, 0))) + return invalid_value(tp, name, NULL, option, err); + } else if (strcasecmp(option, "-priority") == 0) { if ((err = get_u_int(tp, &arg, &s->processPriority, 0))) return invalid_value(tp, name, fs_path, option, err); @@ -1109,6 +1114,10 @@ const char *fcgi_config_set_config(cmd_parms *cmd, void *dummy, const char *arg) if ((err = get_u_int(tp, &arg, &dynamicListenQueueDepth, 1))) return invalid_value(tp, name, NULL, option, err); } + else if (strcasecmp(option, "-min-server-life") == 0) { + if ((err = get_int(tp, &arg, &dynamicMinServerLife, 0))) + return invalid_value(tp, name, NULL, option, err); + } else if (strcasecmp(option, "-restart-delay") == 0) { if ((err = get_u_int(tp, &arg, &dynamicRestartDelay, 0))) return invalid_value(tp, name, NULL, option, err); diff --git a/fcgi_pm.c b/fcgi_pm.c index f389078..348ec35 100644 --- a/fcgi_pm.c +++ b/fcgi_pm.c @@ -1,5 +1,5 @@ /* - * $Id: fcgi_pm.c,v 1.89 2003/10/30 01:08:34 robs Exp $ + * $Id: fcgi_pm.c,v 1.90 2004/01/07 01:56:00 robs Exp $ */ @@ -1707,6 +1707,7 @@ void fcgi_pm_main(void *dummy) int waitStatus; #endif unsigned int numChildren; + unsigned int minServerLife; /* * If we came out of sigsuspend() for any reason other than @@ -1731,6 +1732,10 @@ void fcgi_pm_main(void *dummy) ? dynamicMaxClassProcs : s->numProcesses; + minServerLife = (s->directive == APP_CLASS_DYNAMIC) + ? dynamicMinServerLife + : s->minServerLife; + for (i = 0; i < numChildren; ++i) { if (s->procs[i].pid <= 0 && s->procs[i].state == FCGI_START_STATE) @@ -1753,7 +1758,7 @@ void fcgi_pm_main(void *dummy) { time_t last_start_time = s->procs[i].start_time; - if (last_start_time && now - last_start_time > RUNTIME_SUCCESS_INTERVAL) + if (last_start_time && now - last_start_time > minServerLife) { s->bad = 0; s->numFailures = 0; @@ -1762,7 +1767,7 @@ void fcgi_pm_main(void *dummy) " running for more than %d seconds, its restart" " interval has been restored to %d seconds", (s->directive == APP_CLASS_DYNAMIC) ? " (dynamic)" : "", - s->fs_path, RUNTIME_SUCCESS_INTERVAL, s->restartDelay); + s->fs_path, minServerLife, s->restartDelay); } else { @@ -1773,7 +1778,7 @@ void fcgi_pm_main(void *dummy) if (s->procs[j].pid <= 0) continue; if (s->procs[j].state != FCGI_RUNNING_STATE) continue; if (s->procs[j].start_time == 0) continue; - if (now - s->procs[j].start_time > RUNTIME_SUCCESS_INTERVAL) break; + if (now - s->procs[j].start_time > minServerLife) break; } if (j >= numChildren) @@ -1784,7 +1789,7 @@ void fcgi_pm_main(void *dummy) " running for %d seconds given %d attempts, its restart" " interval has been backed off to %d seconds", (s->directive == APP_CLASS_DYNAMIC) ? " (dynamic)" : "", - s->fs_path, RUNTIME_SUCCESS_INTERVAL, MAX_FAILED_STARTS, + s->fs_path, minServerLife, MAX_FAILED_STARTS, FAILED_STARTS_DELAY); } else @@ -1796,7 +1801,7 @@ void fcgi_pm_main(void *dummy) " running for more than %d seconds, its restart" " interval has been restored to %d seconds", (s->directive == APP_CLASS_DYNAMIC) ? " (dynamic)" : "", - s->fs_path, RUNTIME_SUCCESS_INTERVAL, s->restartDelay); + s->fs_path, minServerLife, s->restartDelay); } } } diff --git a/fcgi_util.c b/fcgi_util.c index 1edcbe8..45d0b9b 100644 --- a/fcgi_util.c +++ b/fcgi_util.c @@ -1,5 +1,5 @@ /* - * $Id: fcgi_util.c,v 1.30 2003/10/30 01:08:34 robs Exp $ + * $Id: fcgi_util.c,v 1.31 2004/01/07 01:56:00 robs Exp $ */ #include "fcgi.h" @@ -417,6 +417,7 @@ fcgi_util_fs_new(pool *p) s->idle_timeout = FCGI_DEFAULT_IDLE_TIMEOUT; s->initStartDelay = DEFAULT_INIT_START_DELAY; s->restartDelay = FCGI_DEFAULT_RESTART_DELAY; + s->minServerLife = FCGI_DEFAULT_MIN_SERVER_LIFE; s->restartOnExit = FALSE; s->directive = APP_CLASS_UNKNOWN; s->processPriority = FCGI_DEFAULT_PRIORITY; diff --git a/mod_fastcgi.c b/mod_fastcgi.c index 35b7e88..05290e1 100644 --- a/mod_fastcgi.c +++ b/mod_fastcgi.c @@ -3,7 +3,7 @@ * * Apache server module for FastCGI. * - * $Id: mod_fastcgi.c,v 1.155 2003/10/30 01:08:34 robs Exp $ + * $Id: mod_fastcgi.c,v 1.156 2004/01/07 01:56:00 robs Exp $ * * Copyright (c) 1995-1996 Open Market, Inc. * @@ -151,6 +151,7 @@ u_int dynamicInitStartDelay = DEFAULT_INIT_START_DELAY; u_int dynamicRestartDelay = FCGI_DEFAULT_RESTART_DELAY; array_header *dynamic_pass_headers = NULL; u_int dynamic_idle_timeout = FCGI_DEFAULT_IDLE_TIMEOUT; +int dynamicMinServerLife = FCGI_DEFAULT_MIN_SERVER_LIFE; /******************************************************************************* * Construct a message and write it to the pm_pipe. diff --git a/mod_fastcgi.h b/mod_fastcgi.h index b8b4905..e290667 100644 --- a/mod_fastcgi.h +++ b/mod_fastcgi.h @@ -1,5 +1,5 @@ /* - * $Id: mod_fastcgi.h,v 1.48 2003/11/25 00:02:19 robs Exp $ + * $Id: mod_fastcgi.h,v 1.49 2004/01/07 01:56:00 robs Exp $ */ #ifndef MOD_FASTCGI_H @@ -42,12 +42,6 @@ #define MAX_FAILED_STARTS 3 /* - * The number of seconds an application has to have run without exiting - * for the application to be considered no longer broken. - */ -#define RUNTIME_SUCCESS_INTERVAL 30 - -/* * The number of seconds between attempts to start an application that * has been declared broken (see MAX_FAILED_STARTS). */ @@ -102,7 +96,9 @@ * seconds a server should wait in * attempt to connect to fcgi app * before sending FCGI_REQUEST_TIMEOUT_JOB */ - +#define FCGI_DEFAULT_MIN_SERVER_LIFE 30 /* the default minimum number of + * seconds a server must stay alive + * before it's considered broken. */ /* * # of sec to wait in a non-blocking connect() to the FastCGI application * before aborting the request, or 0 to indicate that blocking connect()s -- 2.11.4.GIT