From: Amos Jeffries Date: Fri, 17 Jul 2009 13:25:24 +0000 (+1200) Subject: Bug 2680 regression: Crash after rotate with no helpers running X-Git-Tag: SQUID_3_0_STABLE17~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=294971b5a60d275fa1a9cc6c6b182bb60078f3e3;p=thirdparty%2Fsquid.git Bug 2680 regression: Crash after rotate with no helpers running Regression from bug 2276 fix. n_running was used instead of n_active. Also documents the relevant counters to prevent this recurring. --- diff --git a/src/helper.cc b/src/helper.cc index 09e124d48e..6a7eae7af6 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -99,7 +99,7 @@ helperOpenServers(helper * hlp) shortname = xstrdup(progname); /* dont ever start more than hlp->n_to_start processes. */ - int need_new = hlp->n_to_start - hlp->n_running; + int need_new = hlp->n_to_start - hlp->n_active; debugs(84, 1, "helperOpenServers: Starting " << need_new << "/" << hlp->n_to_start << " '" << shortname << "' processes"); @@ -203,7 +203,8 @@ helperStatefulOpenServers(statefulhelper * hlp) shortname = xstrdup(progname); /* dont ever start more than hlp->n_to_start processes. */ - int need_new = hlp->n_to_start - hlp->n_running; + /* n_active are the helpers which have not been shut down. */ + int need_new = hlp->n_to_start - hlp->n_active; debugs(84, 1, "helperOpenServers: Starting " << need_new << "/" << hlp->n_to_start << " '" << shortname << "' processes"); @@ -538,8 +539,8 @@ helperStats(StoreEntry * sentry, helper * hlp, const char *label) storeAppendPrintf(sentry, "program: %s\n", hlp->cmdline->key); - storeAppendPrintf(sentry, "number running: %d of %d\n", - hlp->n_running, hlp->n_to_start); + storeAppendPrintf(sentry, "number active: %d of %d (%d shutting down)\n", + hlp->n_active, hlp->n_to_start, (hlp->n_running - hlp->n_active) ); storeAppendPrintf(sentry, "requests sent: %d\n", hlp->stats.requests); storeAppendPrintf(sentry, "replies received: %d\n", @@ -580,7 +581,7 @@ helperStats(StoreEntry * sentry, helper * hlp, const char *label) storeAppendPrintf(sentry, " B = BUSY\n"); storeAppendPrintf(sentry, " W = WRITING\n"); storeAppendPrintf(sentry, " C = CLOSING\n"); - storeAppendPrintf(sentry, " S = SHUTDOWN\n"); + storeAppendPrintf(sentry, " S = SHUTDOWN PENDING\n"); } void @@ -591,8 +592,8 @@ helperStatefulStats(StoreEntry * sentry, statefulhelper * hlp, const char *label storeAppendPrintf(sentry, "program: %s\n", hlp->cmdline->key); - storeAppendPrintf(sentry, "number running: %d of %d\n", - hlp->n_running, hlp->n_to_start); + storeAppendPrintf(sentry, "number active: %d of %d (%d shutting down)\n", + hlp->n_active, hlp->n_to_start, (hlp->n_running - hlp->n_active) ); storeAppendPrintf(sentry, "requests sent: %d\n", hlp->stats.requests); storeAppendPrintf(sentry, "replies received: %d\n", @@ -637,7 +638,7 @@ helperStatefulStats(StoreEntry * sentry, statefulhelper * hlp, const char *label storeAppendPrintf(sentry, " B = BUSY\n"); storeAppendPrintf(sentry, " C = CLOSING\n"); storeAppendPrintf(sentry, " R = RESERVED or DEFERRED\n"); - storeAppendPrintf(sentry, " S = SHUTDOWN\n"); + storeAppendPrintf(sentry, " S = SHUTDOWN PENDING\n"); storeAppendPrintf(sentry, " P = PLACEHOLDER\n"); } @@ -664,7 +665,6 @@ helperShutdown(helper * hlp) hlp->n_active--; assert(hlp->n_active >= 0); - srv->flags.shutdown = 1; /* request it to shut itself down */ if (srv->flags.closing) { diff --git a/src/helper.h b/src/helper.h index 42239f400f..f5ed077a11 100644 --- a/src/helper.h +++ b/src/helper.h @@ -61,9 +61,9 @@ struct _helper dlink_list servers; dlink_list queue; const char *id_name; - int n_to_start; - int n_running; - int n_active; + int n_to_start; ///< Configuration setting of how many helper children should be running + int n_running; ///< Total helper children objects currently existing + int n_active; ///< Count of helper children active (not shutting down) int ipc_type; unsigned int concurrency; time_t last_queue_warn; @@ -86,9 +86,9 @@ struct _helper_stateful dlink_list servers; dlink_list queue; const char *id_name; - int n_to_start; - int n_running; - int n_active; + int n_to_start; ///< Configuration setting of how many helper children should be running + int n_running; ///< Total helper children objects currently existing + int n_active; ///< Count of helper children active (not shutting down) int ipc_type; MemAllocator *datapool; HLPSAVAIL *IsAvailable;