=== modified file 'src/cf.data.pre' --- src/cf.data.pre 2011-08-03 12:52:39 +0000 +++ src/cf.data.pre 2011-08-07 10:20:33 +0000 @@ -4611,11 +4611,20 @@ LOC: Config.shutdownLifetime DEFAULT: 30 seconds DOC_START - When SIGTERM or SIGHUP is received, the cache is put into - "shutdown pending" mode until all active sockets are closed. - This value is the lifetime to set for all open descriptors - during shutdown mode. Any active clients after this many - seconds will receive a 'timeout' message. + When SIGTERM or SIGHUP is received, Squid begins shutting down. + Shutdown is performed in several stages: + + Stage 1, the cache is put into "shutdown pending" mode until + all active sockets are closed. Or this lifetime is reached. + The main server listening sockets are closed and idle helpers + are disconnected. + + Stage 2, begins at shutdown_lifetime. All remaining components + are disabled and any active clients receive TCP RST. + The cache index is dumped into swap.state. + + Stage 3, begins as soon as stage 2 operations are completed. + Memory is released and Squid workers are terminated. DOC_END COMMENT_START === modified file 'src/main.cc' --- src/main.cc 2011-07-23 08:37:52 +0000 +++ src/main.cc 2011-08-07 10:27:30 +0000 @@ -197,6 +197,8 @@ private: static void StopEventLoop(void * data) { + shutting_down++; + debugs(1, 1, "SHUTDOWN Stage " << shutting_down << ": Halting event loop"); static_cast(data)->loop.stop(); } @@ -232,10 +234,9 @@ void SignalEngine::doShutdown(time_t wait) { - debugs(1, 1, "Preparing for shutdown after " << statCounter.client_http.requests << " requests"); - debugs(1, 1, "Waiting " << wait << " seconds for active connections to finish"); + shutting_down++; + debugs(1, 1, "SHUTDOWN Stage " << shutting_down << ": Preparing for shutdown after " << statCounter.client_http.requests << " requests"); - shutting_down = 1; #if USE_WIN32_SERVICE WIN32_svcstatusupdate(SERVICE_STOP_PENDING, (wait + 1) * 1000); @@ -247,6 +248,8 @@ /* detach the auth components (only do this on full shutdown) */ Auth::Scheme::FreeAll(); #endif + + debugs(1, 1, "Waiting " << wait << " seconds for active connections to finish"); eventAdd("SquidShutdown", &StopEventLoop, this, (double) (wait + 1), 1, false); }