From 6477d3f87e32cc623638073fc1983ebfc4fa54cd Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Tue, 25 Jan 2011 00:26:58 +0100 Subject: [PATCH] make mod_snmp module unload more failsafe --- src/mod/event_handlers/mod_snmp/mod_snmp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mod/event_handlers/mod_snmp/mod_snmp.c b/src/mod/event_handlers/mod_snmp/mod_snmp.c index 040e82b602..36a133c805 100644 --- a/src/mod/event_handlers/mod_snmp/mod_snmp.c +++ b/src/mod/event_handlers/mod_snmp/mod_snmp.c @@ -98,6 +98,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_snmp_load) netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1); init_agent("mod_snmp"); + + /* + * Override master/subagent ping interval to 5s, to ensure that + * agent_check_and_process() never blocks for longer than that. + */ + netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_AGENTX_PING_INTERVAL, 5); + init_subagent(); init_snmp("mod_snmp"); @@ -107,8 +114,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_snmp_load) SWITCH_MODULE_RUNTIME_FUNCTION(mod_snmp_runtime) { - /* block on select() */ - agent_check_and_process(1); + while (!globals.shutdown) { + /* Block on select() */ + agent_check_and_process(1); + } return SWITCH_STATUS_SUCCESS; }