]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
only show the 'preparing for shutdown' message once
authorwessels <>
Tue, 31 Mar 1998 12:34:46 +0000 (12:34 +0000)
committerwessels <>
Tue, 31 Mar 1998 12:34:46 +0000 (12:34 +0000)
src/comm.cc
src/globals.h
src/main.cc
src/redirect.cc

index e48c029fd470a64a9418a3cb67928b234ea31c07..9961d06bebec164fddb6d497963442bd4c67fac1 100644 (file)
@@ -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;
index 7660d9e6e4934a868e30e8f44a713d08f9ecaf37..f8da6e0ab2234a122525cc31f54bf565cbcab30f 100644 (file)
@@ -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 */
index 0e158847a1dade4044b9f8257916285086d1604b..99ff6c4451636df28d41b44317cff32d62db6575 100644 (file)
@@ -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:
index 50572fe2742a621f065b61d800851cf6c36a80d0..19c4e5417dd5835e05999aca58c9569cda71e025 100644 (file)
@@ -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;
     }