]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix closing in/out UDP sockets for both ICP and SNMP
authorwessels <>
Sat, 7 Feb 1998 06:58:03 +0000 (06:58 +0000)
committerwessels <>
Sat, 7 Feb 1998 06:58:03 +0000 (06:58 +0000)
src/icp_v2.cc
src/main.cc
src/protos.h

index d6dbee2bd2a5d326b8cbb7af34bf379d477297e4..47f3051487bd40c536ffd55c7beafc8f365f405f 100644 (file)
@@ -359,7 +359,7 @@ icpConnectionsOpen(void)
        NULL, 0);
     for (s = Config.mcast_group_list; s; s = s->next)
        ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
-    debug(1, 1) ("Accepting ICP messages on port %d, FD %d.\n",
+    debug(12, 1) ("Accepting ICP messages on port %d, FD %d.\n",
        (int) port, theInIcpConnection);
     if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) {
        enter_suid();
@@ -376,7 +376,7 @@ icpConnectionsOpen(void)
            COMM_SELECT_READ,
            icpHandleUdp,
            NULL, 0);
-       debug(1, 1) ("Outgoing ICP messages on port %d, FD %d.\n",
+       debug(12, 1) ("Outgoing ICP messages on port %d, FD %d.\n",
            (int) port, theOutIcpConnection);
        fd_note(theOutIcpConnection, "Outgoing ICP socket");
        fd_note(theInIcpConnection, "Incoming ICP socket");
@@ -395,14 +395,19 @@ icpConnectionsOpen(void)
        theOutICPAddr = xaddr.sin_addr;
 }
 
+/*
+ * icpConnectionShutdown only closes the 'in' socket if it is 
+ * different than the 'out' socket.
+ */
 void
-icpConnectionsClose(void)
+icpConnectionShutdown(void)
 {
     if (theInIcpConnection < 0)
        return;
-    debug(1, 1) ("FD %d Closing ICP connection\n", theInIcpConnection);
-    if (theInIcpConnection != theOutIcpConnection)
+    if (theInIcpConnection != theOutIcpConnection) {
+        debug(12, 1) ("FD %d Closing ICP connection\n", theInIcpConnection);
        comm_close(theInIcpConnection);
+    }
     /*
      * Here we set 'theInIcpConnection' to -1 even though the ICP 'in'
      * and 'out' sockets might be just one FD.  This prevents this
@@ -419,3 +424,13 @@ icpConnectionsClose(void)
     assert(theOutIcpConnection > -1);
     commSetSelect(theOutIcpConnection, COMM_SELECT_READ, NULL, NULL, 0);
 }
+
+void
+icpConnectionClose(void)
+{
+    icpConnectionShutdown();
+    if (theOutIcpConnection > -1) {
+        debug(12, 1) ("FD %d Closing ICP connection\n", theOutIcpConnection);
+       comm_close(theOutIcpConnection);
+    }
+}
index 7d50aa3150c5206157a3b3f01f33fc67c802606c..6ccd5042fb351e00107a2beae56a5fc841035221 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.214 1998/02/06 17:30:53 wessels Exp $
+ * $Id: main.cc,v 1.215 1998/02/06 23:58:04 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -339,10 +339,10 @@ serverConnectionsClose(void)
      * is pending
      */
     clientHttpConnectionsClose();
-    icpConnectionsClose();
+    icpConnectionShutdown();
     icmpClose();
 #ifdef SQUID_SNMP
-    snmpConnectionClose();
+    snmpConnectionShutdown();
 #endif
 }
 
@@ -352,16 +352,14 @@ mainReconfigure(void)
     debug(1, 0) ("Restarting Squid Cache (version %s)...\n", version_string);
     /* Already called serverConnectionsClose and ipcacheShutdownServers() */
     serverConnectionsClose();
-    if (theOutIcpConnection > 0) {
-       comm_close(theOutIcpConnection);
-       theOutIcpConnection = -1;
-    }
+    icpConnectionClose();
+#ifdef SQUID_SNMP
+    snmpConnectionClose();
+#endif
     dnsShutdownServers();
     asnCleanup();
     redirectShutdownServers();
-#if 0
     storeDirCloseSwapLogs();
-#endif
     errorFree();
     parseConfigFile(ConfigFile);
     _db_init(Config.Log.log, Config.debugOptions);
@@ -601,10 +599,8 @@ main(int argc, char **argv)
            break;
        case COMM_SHUTDOWN:
            /* delayed close so we can transmit while shutdown pending */
-           if (theOutIcpConnection > 0) {
-               comm_close(theOutIcpConnection);
-               theOutIcpConnection = -1;
-           }
+           icpConnectionClose();
+           snmpConnectionClose();
            if (shutdown_pending) {
                normal_shutdown();
 #if 0
index 6d1039dc2690a84e80a0d7f5031d9de45f8c65ec..9eda3bae9c4c5adf838217a356ed2a091987db43 100644 (file)
@@ -244,6 +244,7 @@ extern DEFER httpAcceptDefer;
 extern PF snmpHandleUdp;
 extern void snmpInit(void);
 extern void snmpConnectionOpen(void);
+extern void snmpConnectionShutdown(void);
 extern void snmpConnectionClose(void);
 extern int create_view(char **);
 extern int create_user(char **);
@@ -257,7 +258,8 @@ extern PF icpUdpReply;
 extern void icpHandleIcpV3(int, struct sockaddr_in, char *, int);
 extern int icpCheckUdpHit(StoreEntry *, request_t * request);
 extern void icpConnectionsOpen(void);
-extern void icpConnectionsClose(void);
+extern void icpConnectionShutdown(void);
+extern void icpConnectionClose(void);
 
 extern void ipcache_nbgethostbyname(const char *name,
     IPH * handler,