]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
clean up reconfigure/rotate/shutdown flags and stuff
authorwessels <>
Tue, 31 Mar 1998 11:09:48 +0000 (11:09 +0000)
committerwessels <>
Tue, 31 Mar 1998 11:09:48 +0000 (11:09 +0000)
src/cache_cf.cc
src/comm.cc
src/globals.h
src/main.cc
src/redirect.cc

index 8a3fdc3c8c16f2328291718a8c644fd3318f0680..19130b29df722df85a2b090a37120646c7466ee8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.267 1998/03/28 18:37:05 wessels Exp $
+ * $Id: cache_cf.cc,v 1.268 1998/03/31 04:09:48 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -613,7 +613,7 @@ free_cachedir(cacheSwap * swap)
     SwapDir *s;
     int i;
     /* DON'T FREE THESE FOR RECONFIGURE */
-    if (reconfigure_pending)
+    if (reconfiguring)
        return;
     for (i = 0; i < swap->n_configured; i++) {
        s = swap->swapDirs + i;
index 6bc65d93d22636e5e4a1a9692074113c703ae57d..e48c029fd470a64a9418a3cb67928b234ea31c07 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.239 1998/03/28 23:24:44 wessels Exp $
+ * $Id: comm.cc,v 1.240 1998/03/31 04:09:49 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 || reconfigure_pending) {
+    if (shutdown_pending) {
        /* don't increase the timeout if something pending */
        if (F->timeout > 0 && (int) (F->timeout - squid_curtime) < timeout)
            return F->timeout;
@@ -888,8 +888,7 @@ comm_poll(time_t sec)
            /* shutdown_pending will be set to
             * +1 for SIGTERM
             * -1 for SIGINT */
-           /* reconfigure_pending always == 1 when SIGHUP received */
-           if (shutdown_pending > 0 || reconfigure_pending > 0)
+           if (shutdown_pending > 0)
                setSocketShutdownLifetimes(Config.shutdownLifetime);
            else
                setSocketShutdownLifetimes(1);
@@ -915,7 +914,7 @@ comm_poll(time_t sec)
                nfds++;
            }
        }
-       if (shutdown_pending || reconfigure_pending)
+       if (shutdown_pending)
            debug(5, 2) ("comm_poll: Still waiting on %d FDs\n", nfds);
        if (nfds == 0)
            return COMM_SHUTDOWN;
@@ -1040,15 +1039,14 @@ comm_select(time_t sec)
 
        FD_ZERO(&readfds);
        FD_ZERO(&writefds);
-       if (shutdown_pending || reconfigure_pending) {
+       if (shutdown_pending) {
            serverConnectionsClose();
            dnsShutdownServers();
            redirectShutdownServers();
            /* shutdown_pending will be set to
             * +1 for SIGTERM
             * -1 for SIGINT */
-           /* reconfigure_pending always == 1 when SIGHUP received */
-           if (shutdown_pending > 0 || reconfigure_pending > 0)
+           if (shutdown_pending > 0)
                setSocketShutdownLifetimes(Config.shutdownLifetime);
            else
                setSocketShutdownLifetimes(1);
@@ -1067,7 +1065,7 @@ comm_select(time_t sec)
                FD_SET(i, &writefds);
            }
        }
-       if (shutdown_pending || reconfigure_pending)
+       if (shutdown_pending)
            debug(5, 2) ("comm_select: Still waiting on %d FDs\n", nfds);
        if (nfds == 0)
            return COMM_SHUTDOWN;
index 31af1a9cdab7824dca77fd3c8b0be46820890d20..7660d9e6e4934a868e30e8f44a713d08f9ecaf37 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.44 1998/03/29 08:50:59 wessels Exp $
+ * $Id: globals.h,v 1.45 1998/03/31 04:09:50 wessels Exp $
  */
 
 extern FILE *debug_log;                /* NULL */
@@ -80,8 +80,8 @@ extern struct in_addr theOutSNMPAddr;
 extern struct timeval current_time;
 extern struct timeval squid_start;
 extern time_t squid_curtime;   /* 0 */
-extern volatile int reconfigure_pending;       /* 0 */
 extern volatile int shutdown_pending;  /* 0 */
+extern int reconfiguring;      /* 0 */
 extern int store_rebuilding;   /* 1 */
 extern int store_swap_size;    /* 0 */
 extern unsigned long store_mem_size;   /* 0 */
index ba8eab1e203e9ffc7bc5ca89d046bdc2cf25e90d..f190d86072f884b0e0c5a68ef88de244c3b9ffc0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.239 1998/03/28 23:24:48 wessels Exp $
+ * $Id: main.cc,v 1.240 1998/03/31 04:09:51 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -111,20 +111,22 @@ extern void (*failure_notify) (const char *);
 
 static int opt_send_signal = -1;
 static int opt_no_daemon = 0;
-static volatile int rotate_pending = 0;                /* set by SIGUSR1 handler */
 static int httpPortNumOverride = 1;
 static int icpPortNumOverride = 1;     /* Want to detect "-u 0" */
 #if MALLOC_DBG
 static int malloc_debug_level = 0;
 #endif
+static volatile int do_reconfigure = 0;
+static volatile int do_rotate = 0;
 
+static void mainRotate(void);
+static void mainReconfigure(void);
 static SIGHDLR rotate_logs;
 static SIGHDLR reconfigure;
 #if ALARM_UPDATES_TIME
 static SIGHDLR time_tick;
 #endif
 static void mainInitialize(void);
-static void mainReconfigure(void);
 static void usage(void);
 static void mainParseOptions(int, char **);
 static void sendSignal(void);
@@ -278,8 +280,7 @@ mainParseOptions(int argc, char *argv[])
 static void
 rotate_logs(int sig)
 {
-    debug(1, 1) ("rotate_logs: SIGUSR1 received.\n");
-    rotate_pending = 1;
+    do_rotate = 1;
 #if !HAVE_SIGACTION
     signal(sig, rotate_logs);
 #endif
@@ -302,7 +303,7 @@ time_tick(int sig)
 static void
 reconfigure(int sig)
 {
-    reconfigure_pending = 1;
+    do_reconfigure = 1;
 #if !HAVE_SIGACTION
     signal(sig, reconfigure);
 #endif
@@ -312,17 +313,10 @@ void
 shut_down(int sig)
 {
     shutdown_pending = sig == SIGINT ? -1 : 1;
-    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);
 #ifdef KILL_PARENT_OPT
-    {
-       pid_t ppid = getppid();
-       if (ppid > 1) {
-           debug(1, 1) ("Killing RunCache, pid %d\n", ppid);
-           kill(ppid, sig);
-       }
+    if (getppid() > 1) {
+       debug(1, 1) ("Killing RunCache, pid %d\n", getppid());
+       kill(getppid(), sig);
     }
 #endif
 #if SA_RESETHAND == 0
@@ -368,6 +362,7 @@ static void
 mainReconfigure(void)
 {
     debug(1, 0) ("Restarting Squid Cache (version %s)...\n", version_string);
+    reconfiguring = 1;
     /* Already called serverConnectionsClose and ipcacheShutdownServers() */
     serverConnectionsClose();
     icpConnectionClose();
@@ -392,6 +387,19 @@ mainReconfigure(void)
        neighbors_open(theOutIcpConnection);
     storeDirOpenSwapLogs();
     debug(1, 0) ("Ready to serve requests.\n");
+    reconfiguring = 0;
+}
+
+static void
+mainRotate(void)
+{
+    icmpClose();
+    _db_rotate_log();          /* cache.log */
+    storeDirWriteCleanLogs(1);
+    storeLogRotate();          /* store.log */
+    accessLogRotate();         /* access.log */
+    useragentRotateLog();      /* useragent.log */
+    icmpOpen();
 }
 
 static void
@@ -589,18 +597,17 @@ main(int argc, char **argv)
 
     /* main loop */
     for (;;) {
-       if (reconfigure_pending) {
+       if (do_reconfigure) {
            mainReconfigure();
-           reconfigure_pending = 0;    /* reset */
-       } else if (rotate_pending) {
-           icmpClose();
-           _db_rotate_log();   /* cache.log */
-           storeDirWriteCleanLogs(1);
-           storeLogRotate();   /* store.log */
-           accessLogRotate();  /* access.log */
-           useragentRotateLog();       /* useragent.log */
-           icmpOpen();
-           rotate_pending = 0;
+           do_reconfigure = 0;
+       } else if (do_rotate) {
+           mainRotate();
+           do_rotate = 0;
+       } else if (shutdown_pending) {
+           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);
        }
        eventRun();
        if ((loop_delay = eventNextTime()) < 0)
@@ -692,8 +699,7 @@ watch_child(char *argv[])
            execvp(prog, argv);
            fatal("execvp failed");
        }
-       /* parent */
-       time(&start);
+       /* parent */ time(&start);
        do {
            squid_signal(SIGINT, SIG_IGN, SA_RESTART);
 #ifdef _SQUID_NEXT_
index 401badc2331aa90beb1aae31ac709bce28cc38e7..50572fe2742a621f065b61d800851cf6c36a80d0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: redirect.cc,v 1.57 1998/03/03 00:31:12 rousskov Exp $
+ * $Id: redirect.cc,v 1.58 1998/03/31 04:09:51 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 && !reconfigure_pending)
+       if (--NRedirectorsOpen == 0 && !shutdown_pending)
            fatal_dump("All redirectors have exited!");
        return;
     }