#if USE_ADAPTATION
#include "adaptation/Config.h"
#endif
-#if SQUID_SNMP
-#include "snmp_core.h"
-#endif
#include <cerrno>
#if HAVE_GETOPT_H
#if USE_HTCP
htcpOpenPorts();
#endif
-#if SQUID_SNMP
- snmpOpenPorts();
-#endif
-
icmpEngine.Open();
netdbInit();
Acl::Node::Initialize();
#endif
icmpEngine.Close();
-#if SQUID_SNMP
- snmpClosePorts();
-#endif
}
}
icapLogOpen();
#endif
-#if SQUID_SNMP
-
- snmpInit();
-
-#endif
#if MALLOC_DBG
malloc_debug(0, malloc_debug_level);
CallRunnerRegistratorIn(Rock, SwapDirRr);
#endif
+#if SQUID_SNMP
+ CallRunnerRegistrator(SnmpRr);
+#endif
+
#if USE_WCCP
CallRunnerRegistrator(WccpRr);
#endif
icpClosePorts();
#if USE_HTCP
htcpClosePorts();
-#endif
-#if SQUID_SNMP
- snmpClosePorts();
#endif
releaseServerSockets();
commCloseAllSockets();
#include "acl/FilledChecklist.h"
#include "base/AsyncCallbacks.h"
#include "base/CbcPointer.h"
+#include "base/RunnersRegistry.h"
#include "CachePeer.h"
#include "CachePeers.h"
#include "client_db.h"
static mib_tree_entry *snmpTreeSiblingEntry(oid entry, snint len, mib_tree_entry * current);
extern "C" void snmpSnmplibDebug(int lvl, char *buf);
-/*
- * The functions used during startup:
- * snmpInit
- * snmpConnectionOpen
- * snmpConnectionClose
- */
-
/*
* Turns the MIB into a Tree structure. Called during the startup process.
*/
-void
-snmpInit(void)
+static void
+snmpInit()
{
+ if (!IamWorkerProcess())
+ return;
+
debugs(49, 5, "snmpInit: Building SNMP mib tree structure");
snmplib_debug_hook = snmpSnmplibDebug;
debugs(49, 9, "snmpInit: Completed SNMP mib tree structure");
}
-void
-snmpOpenPorts(void)
+static void
+snmpOpenPorts()
{
- debugs(49, 5, "snmpConnectionOpen: Called");
+ if (!IamWorkerProcess())
+ return;
if (Config.Port.snmp <= 0)
return;
fatalf("Lost SNMP port (%d) on FD %d", (int)conn->local.port(), conn->fd);
}
-void
-snmpClosePorts(void)
+static void
+snmpClosePorts()
{
+ if (!IamWorkerProcess())
+ return;
+
if (Comm::IsConnOpen(snmpIncomingConn)) {
debugs(49, DBG_IMPORTANT, "Closing SNMP receiving port " << snmpIncomingConn->local);
snmpIncomingConn->close();
snmpOutgoingConn = nullptr;
}
-/*
- * Functions for handling the requests.
- */
+class SnmpRr : public RegisteredRunner
+{
+public:
+ void finalizeConfig() override { snmpInit(); }
+ void useConfig() override { snmpOpenPorts(); }
+ void startReconfigure() override { snmpClosePorts(); }
+ void syncConfig() override { snmpOpenPorts(); }
+ void startShutdown() override { snmpClosePorts(); }
+};
+DefineRunnerRegistrator(SnmpRr);
/*
* Accept the UDP packet
extern Comm::ConnectionPointer snmpOutgoingConn;
extern PF snmpHandleUdp;
-void snmpInit(void);
-void snmpOpenPorts(void);
-void snmpClosePorts(void);
const char * snmpDebugOid(oid * Name, snint Len, MemBuf &outbuf);
void addr2oid(Ip::Address &addr, oid *Dest);
void oid2addr(oid *Dest, Ip::Address &addr, u_int code);