From: Amos Jeffries Date: Thu, 3 Nov 2011 10:02:02 +0000 (+1300) Subject: Bug 3364: SNMP Orphans X-Git-Tag: BumpSslServerFirst.take01~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f335cb1b6b88cdf3185ced5ee3ba5f61f5f9ba2;p=thirdparty%2Fsquid.git Bug 3364: SNMP Orphans --- diff --git a/src/main.cc b/src/main.cc index 068f862616..6d17cb60b3 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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 diff --git a/src/protos.h b/src/protos.h index 00bae33f82..e39e135d96 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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); diff --git a/src/snmp_core.cc b/src/snmp_core.cc index 7f2b8d4204..fd36968779 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -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; }