Hello,
I have a question regarding the perl cleanup in snnmptrapd. Why shutdown_perl()
is called from withithin the term_handler() routine in snmptrapd.c? The problem
we are seeing is that if a TERM signal is caught while a perl handler is still
processing an incoming trap, then snmptrapd fails to cleanup the perl, as it
can not free up the active subroutine.
We get the warning "Can't undef active subroutine" from Perl_cv_undef() as it
croaks. This is specifically problematic in SNMPv3 environments as then
snmptrapd fails to increment engineBoots in the persistent data file, leading
to a reuse of the same engineBoots on the next startup, which would then break
time synchronization.
Wouldn't it be better to call shutdown_perl() after the while(netsnmp_running)
loop, where the rest of the c cleanup code, ie snmp_shutdown is called? This
assumes that any perl based trap handlers have completed before shutting down
the perl interpreter.
The attached diff is based on the 5.5 version, but could be applied to trunk.
Index: apps/snmptrapd.c
===================================================================
--- apps/snmptrapd.c (revision 558)
+++ apps/snmptrapd.c (working copy)
@@ -313,10 +313,6 @@
#endif
netsnmp_running = 0;
-#ifdef NETSNMP_EMBEDDED_PERL
- shutdown_perl();
-#endif
-
#ifdef WIN32SERVICE
/*
* In case of windows, select() in receive() function will not return
@@ -1311,6 +1307,10 @@
tm->tm_min, tm->tm_sec, netsnmp_get_version());
}
snmp_log(LOG_INFO, "Stopping snmptrapd\n");
+
+#ifdef NETSNMP_EMBEDDED_PERL
+ shutdown_perl();
+#endif
snmptrapd_close_sessions(sess_list);
snmp_shutdown("snmptrapd");
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders