]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3364: SNMP Orphans
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 3 Nov 2011 10:02:02 +0000 (23:02 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 3 Nov 2011 10:02:02 +0000 (23:02 +1300)
src/main.cc
src/protos.h
src/snmp_core.cc

index 068f862616c5d21e2b42af5c4d7e858e74be806c..6d17cb60b33df93081b885c53851587e70cf40b2 100644 (file)
@@ -670,7 +670,6 @@ serverConnectionsOpen(void)
         htcpInit();
 #endif
 #if SQUID_SNMP
-
         snmpConnectionOpen();
 #endif
 
@@ -714,8 +713,7 @@ serverConnectionsClose(void)
 
         icmpEngine.Close();
 #if SQUID_SNMP
-
-        snmpConnectionShutdown();
+        snmpConnectionClose();
 #endif
 
         asnFreeMemory();
@@ -735,10 +733,6 @@ mainReconfigureStart(void)
 
     htcpSocketClose();
 #endif
-#if SQUID_SNMP
-
-    snmpConnectionClose();
-#endif
 #if USE_DNSSERVERS
 
     dnsShutdown();
@@ -1867,7 +1861,6 @@ SquidShutdown()
     htcpSocketClose();
 #endif
 #if SQUID_SNMP
-
     snmpConnectionClose();
 #endif
 #if USE_WCCP
index 00bae33f82fa7f99976eec082568836b1c5bb89e..e39e135d9606e29a9d3f6a27645ba83ed8bca6b1 100644 (file)
@@ -272,7 +272,6 @@ SQUIDCEXTERN int httpReqHdrManglersConfigured();
 SQUIDCEXTERN PF snmpHandleUdp;
 SQUIDCEXTERN void snmpInit(void);
 SQUIDCEXTERN void snmpConnectionOpen(void);
-SQUIDCEXTERN void snmpConnectionShutdown(void);
 SQUIDCEXTERN void snmpConnectionClose(void);
 SQUIDCEXTERN const char * snmpDebugOid(oid * Name, snint Len, MemBuf &outbuf);
 
index 7f2b8d420477e2a82eb7894972bbc9bf5a8a4aee..fd36968779c5b5ce7ad9658c44757635f85a0de2 100644 (file)
@@ -92,7 +92,6 @@ extern "C" void snmpSnmplibDebug(int lvl, char *buf);
  * The functions used during startup:
  * snmpInit
  * snmpConnectionOpen
- * snmpConnectionShutdown
  * snmpConnectionClose
  */
 
@@ -356,36 +355,20 @@ snmpPortOpened(const Comm::ConnectionPointer &conn, int errNo)
         fatalf("Lost SNMP port (%d) on FD %d", (int)conn->local.GetPort(), conn->fd);
 }
 
-void
-snmpConnectionShutdown(void)
-{
-    if (!Comm::IsConnOpen(snmpIncomingConn))
-        return;
-
-    // Perform lazy closure. So as not to step on outgoing connection when sharing.
-    debugs(49, DBG_IMPORTANT, "Closing SNMP receiving port " << snmpIncomingConn->local);
-    snmpIncomingConn = NULL;
-
-    /*
-     * Normally we only write to the outgoing SNMP socket, but we
-     * also have a read handler there to catch messages sent to that
-     * specific interface.  During shutdown, we must disable reading
-     * on the outgoing socket.
-     */
-    assert(Comm::IsConnOpen(snmpOutgoingConn));
-
-    Comm::SetSelect(snmpOutgoingConn->fd, COMM_SELECT_READ, NULL, NULL, 0);
-}
-
 void
 snmpConnectionClose(void)
 {
-    snmpConnectionShutdown();
-
-    if (!Comm::IsConnOpen(snmpOutgoingConn))
-        return;
+    if (!Comm::IsConnOpen(snmpIncomingConn)) {
+        debugs(49, DBG_IMPORTANT, "Closing SNMP receiving port " << snmpIncomingConn->local);
+        snmpIncomingConn->close();
+    }
+    snmpIncomingConn = NULL;
 
-    debugs(49, DBG_IMPORTANT, "Closing SNMP sending port " << snmpOutgoingConn->local);
+    if (!Comm::IsConnOpen(snmpOutgoingConn) && snmpIncomingConn != snmpOutgoingConn) {
+        // Perform OUT port closure so as not to step on IN port when sharing a conn.
+        debugs(49, DBG_IMPORTANT, "Closing SNMP sending port " << snmpOutgoingConn->local);
+        snmpOutgoingConn->close();
+    }
     snmpOutgoingConn = NULL;
 }