From: wessels <> Date: Tue, 31 Mar 1998 12:34:46 +0000 (+0000) Subject: only show the 'preparing for shutdown' message once X-Git-Tag: SQUID_3_0_PRE1~3684 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2681d383bd49f1df553662c938fb85c6cfaae386;p=thirdparty%2Fsquid.git only show the 'preparing for shutdown' message once --- diff --git a/src/comm.cc b/src/comm.cc index e48c029fd4..9961d06beb 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.240 1998/03/31 04:09:49 wessels Exp $ + * $Id: comm.cc,v 1.241 1998/03/31 05:34:46 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -482,7 +482,7 @@ commSetTimeout(int fd, int timeout, PF * handler, void *data) F->timeout_data = NULL; return F->timeout = 0; } - if (shutdown_pending) { + if (shutting_down) { /* don't increase the timeout if something pending */ if (F->timeout > 0 && (int) (F->timeout - squid_curtime) < timeout) return F->timeout; @@ -633,7 +633,7 @@ comm_close(int fd) F = &fd_table[fd]; if (EBIT_TEST(F->flags, FD_CLOSING)) return; - if (shutdown_pending && (!F->open || F->type == FD_FILE)) + if (shutting_down && (!F->open || F->type == FD_FILE)) return; assert(F->open); assert(F->type != FD_FILE); @@ -881,14 +881,14 @@ comm_poll(time_t sec) #if !ALARM_UPDATES_TIME getCurrentTime(); #endif - if (shutdown_pending) { + if (shutting_down) { serverConnectionsClose(); dnsShutdownServers(); redirectShutdownServers(); - /* shutdown_pending will be set to + /* shutting_down will be set to * +1 for SIGTERM * -1 for SIGINT */ - if (shutdown_pending > 0) + if (shutting_down > 0) setSocketShutdownLifetimes(Config.shutdownLifetime); else setSocketShutdownLifetimes(1); @@ -914,7 +914,7 @@ comm_poll(time_t sec) nfds++; } } - if (shutdown_pending) + if (shutting_down) debug(5, 2) ("comm_poll: Still waiting on %d FDs\n", nfds); if (nfds == 0) return COMM_SHUTDOWN; @@ -1039,14 +1039,14 @@ comm_select(time_t sec) FD_ZERO(&readfds); FD_ZERO(&writefds); - if (shutdown_pending) { + if (shutting_down) { serverConnectionsClose(); dnsShutdownServers(); redirectShutdownServers(); - /* shutdown_pending will be set to + /* shutting_down will be set to * +1 for SIGTERM * -1 for SIGINT */ - if (shutdown_pending > 0) + if (shutting_down > 0) setSocketShutdownLifetimes(Config.shutdownLifetime); else setSocketShutdownLifetimes(1); @@ -1065,7 +1065,7 @@ comm_select(time_t sec) FD_SET(i, &writefds); } } - if (shutdown_pending) + if (shutting_down) debug(5, 2) ("comm_select: Still waiting on %d FDs\n", nfds); if (nfds == 0) return COMM_SHUTDOWN; diff --git a/src/globals.h b/src/globals.h index 7660d9e6e4..f8da6e0ab2 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.45 1998/03/31 04:09:50 wessels Exp $ + * $Id: globals.h,v 1.46 1998/03/31 05:34:47 wessels Exp $ */ extern FILE *debug_log; /* NULL */ @@ -80,7 +80,7 @@ extern struct in_addr theOutSNMPAddr; extern struct timeval current_time; extern struct timeval squid_start; extern time_t squid_curtime; /* 0 */ -extern volatile int shutdown_pending; /* 0 */ +extern int shutting_down; /* 0 */ extern int reconfiguring; /* 0 */ extern int store_rebuilding; /* 1 */ extern int store_swap_size; /* 0 */ diff --git a/src/main.cc b/src/main.cc index 0e158847a1..99ff6c4451 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.241 1998/03/31 04:45:24 wessels Exp $ + * $Id: main.cc,v 1.242 1998/03/31 05:34:48 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -118,6 +118,7 @@ static int malloc_debug_level = 0; #endif static volatile int do_reconfigure = 0; static volatile int do_rotate = 0; +static volatile int do_shutdown = 0; static void mainRotate(void); static void mainReconfigure(void); @@ -312,7 +313,7 @@ reconfigure(int sig) void shut_down(int sig) { - shutdown_pending = sig == SIGINT ? -1 : 1; + do_shutdown = sig == SIGINT ? -1 : 1; #ifdef KILL_PARENT_OPT if (getppid() > 1) { debug(1, 1) ("Killing RunCache, pid %d\n", getppid()); @@ -609,11 +610,13 @@ main(int argc, char **argv) } else if (do_rotate) { mainRotate(); do_rotate = 0; - } else if (shutdown_pending) { + } else if (do_shutdown) { debug(1, 1) ("Preparing for shutdown after %d requests\n", Counter.client_http.requests); debug(1, 1) ("Waiting %d seconds for active connections to finish\n", - shutdown_pending > 0 ? (int) Config.shutdownLifetime : 0); + do_shutdown > 0 ? (int) Config.shutdownLifetime : 0); + do_shutdown = 0; + shutting_down = 1; } eventRun(); if ((loop_delay = eventNextTime()) < 0) @@ -641,10 +644,10 @@ main(int argc, char **argv) #ifdef SQUID_SNMP snmpConnectionClose(); #endif - if (shutdown_pending) { + if (shutting_down) { normal_shutdown(); } else { - fatal_dump("MAIN: SHUTDOWN from comm_select, but nothing pending."); + fatal_dump("MAIN: Unexpected SHUTDOWN from comm_select."); } break; case COMM_TIMEOUT: diff --git a/src/redirect.cc b/src/redirect.cc index 50572fe274..19c4e5417d 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.58 1998/03/31 04:09:51 wessels Exp $ + * $Id: redirect.cc,v 1.59 1998/03/31 05:34:48 wessels Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -105,7 +105,7 @@ redirectHandleRead(int fd, void *data) memFree(MEM_8K_BUF, redirector->inbuf); redirector->inbuf = NULL; comm_close(fd); - if (--NRedirectorsOpen == 0 && !shutdown_pending) + if (--NRedirectorsOpen == 0 && !shutting_down) fatal_dump("All redirectors have exited!"); return; }