]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleaned up reconfiguration sequence.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 11 Sep 2008 06:32:57 +0000 (00:32 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 11 Sep 2008 06:32:57 +0000 (00:32 -0600)
mainReconfigure() used to close and then open various sockets. Since
comm_close is now asynchronous, one cannot close and open in the same
function. Split mainReconfigure into mainReconfigureStart (that starts
the closing process for all relevant sockets) and mainReconfigureFinish
that opens the new sockets.

serverConnectionsClose is only used by main.cc and, hence, can be static.

Polished comments and added an XXX comment on why SquidShutdown is broken.

Also removed commCheckHalfClosed event scheduling. A separate cleanup patch
removes the associated half-closed monitoring loop.

src/main.cc
src/protos.h

index e98c47942676f6a9ffd21250fee53cf6619cd996..6eaea0acded0a3300a63323fd7d65e022ea3e480 100644 (file)
@@ -111,12 +111,14 @@ static volatile int do_shutdown = 0;
 static volatile int shutdown_status = 0;
 
 static void mainRotate(void);
-static void mainReconfigure(void);
+static void mainReconfigureStart(void);
+static void mainReconfigureFinish(void*);
 static void mainInitialize(void);
 static void usage(void);
 static void mainParseOptions(int argc, char *argv[]);
 static void sendSignal(void);
 static void serverConnectionsOpen(void);
+static void serverConnectionsClose(void);
 static void watch_child(char **);
 static void setEffectiveUser(void);
 #if MEM_GEN_TRACE
@@ -172,7 +174,7 @@ SignalEngine::checkEvents(int timeout)
     PROF_start(SignalEngine_checkEvents);
 
     if (do_reconfigure) {
-        mainReconfigure();
+        mainReconfigureStart();
         do_reconfigure = 0;
     } else if (do_rotate) {
         mainRotate();
@@ -629,7 +631,7 @@ serverConnectionsOpen(void)
     peerSourceHashInit();
 }
 
-void
+static void
 serverConnectionsClose(void)
 {
     assert(shutting_down || reconfiguring);
@@ -658,11 +660,12 @@ serverConnectionsClose(void)
 }
 
 static void
-mainReconfigure(void)
+mainReconfigureStart(void)
 {
     debugs(1, 1, "Reconfiguring Squid Cache (version " << version_string << ")...");
     reconfiguring = 1;
-    /* Already called serverConnectionsClose and ipcacheShutdownServers() */
+
+    // Initiate asynchronous closing sequence
     serverConnectionsClose();
     icpConnectionClose();
 #if USE_HTCP
@@ -689,6 +692,15 @@ mainReconfigure(void)
     accessLogClose();
     useragentLogClose();
     refererCloseLog();
+
+    eventAdd("mainReconfigureFinish", &mainReconfigureFinish, NULL, 0, 1,
+        false);
+}
+
+static void
+mainReconfigureFinish(void *) {
+    debugs(1, 3, "finishing reconfiguring");
+
     errorClean();
     enter_suid();              /* root to read config file */
     parseConfigFile(ConfigFile);
@@ -1065,8 +1077,6 @@ mainInitialize(void)
 #endif
 
         eventAdd("memPoolCleanIdlePools", Mem::CleanIdlePools, NULL, 15.0, 1);
-
-        eventAdd("commCheckHalfClosed", commCheckHalfClosed, NULL, 1.0, false);
     }
 
     configured_once = 1;
@@ -1597,6 +1607,12 @@ watch_child(char *argv[])
 static void
 SquidShutdown()
 {
+    /* XXX: This function is called after the main loop has quit, which
+     * means that no AsyncCalls would be called, including close handlers.
+     * TODO: We need to close/shut/free everything that needs calls before
+     * exiting the loop.
+     */ 
+
 #if USE_WIN32_SERVICE
     WIN32_svcstatusupdate(SERVICE_STOP_PENDING, 10000);
 #endif
index b18b0b14499770bd4aac7dac3eca653f46fc10e4..169d9041025e04d3309061530d91546a690561c1 100644 (file)
@@ -458,7 +458,6 @@ extern time_t getMaxAge(const char *url);
 extern void refreshInit(void);
 extern const refresh_t *refreshLimits(const char *url);
 
-extern void serverConnectionsClose(void);
 extern void shut_down(int);
 extern void rotate_logs(int);
 extern void reconfigure(int);