Hi all,
This is my first post to the list. I've been playing around with the
Net-SNMP API for a week or two, and have gone so far as writing a simple
SNMP module for the open source SIP soft-switch, FreeSWITCH. My module
is based loosely on the example given in the Net-SNMP wiki, about how to
write an AgentX subagent. Source is viewable at
http://fisheye.freeswitch.org/browse/freeswitch.git/src/mod/event_handlers/mod_snmp
- any feedback or comments welcome.
I noticed while developing the module that if left to run for a few
hours, the module unload thread would hand when shutting down. Also, if
I reload the module repeatedly in succession, every so often it will
hang (again, in the module unload).
I'm using agent_check_and_process(1), so that it blocks in the select().
When the module unloads, snmp_shutdown("mod_snmp") is getting called (by
a different thread), which I (among other things) I presume is closing
the socket. This should cause the select() to return.
I captured thread backtraces with gdb when the thread hangs, working
with both 5.4.3 (since most Linux distros still ship this) and 5.6.1.
Sorry in advance about the long lines.
5.4:
Thread 30 (Thread 0x7fffe70f1700 (LWP 10750)):
#0 0x00007ffff6cdb233 in recvfrom () from /lib/libpthread.so.0
#1 0x00007fffed5bbf71 in ?? () from /usr/lib/libnetsnmp.so.15
#2 0x00007fffed58d68e in _sess_read () from /usr/lib/libnetsnmp.so.15
#3 0x00007fffed58e539 in snmp_sess_read () from /usr/lib/libnetsnmp.so.15
#4 0x00007fffed58e58b in snmp_read () from /usr/lib/libnetsnmp.so.15
#5 0x00007fffed5666f8 in snmp_synch_response_cb () from
/usr/lib/libnetsnmp.so.15
#6 0x00007fffeddb53ca in agentx_close_session () from
/usr/lib/libnetsnmpagent.so.15
#7 0x00007fffedda3d43 in ?? () from /usr/lib/libnetsnmpagent.so.15
#8 0x00007fffed5aad9c in snmp_call_callbacks () from
/usr/lib/libnetsnmp.so.15
#9 0x00007fffed585997 in snmp_shutdown () from /usr/lib/libnetsnmp.so.15
#10 0x00007fffedfc80e2 in mod_snmp_shutdown () at
/usr/src/freeswitch/src/mod/event_handlers/mod_snmp/mod_snmp.c:119
#11 0x00007ffff75a92a0 in do_shutdown (module=0x7ffff00b6848,
shutdown=<value optimized out>, unload=<value optimized out>,
fail_if_busy=SWITCH_TRUE, err=<value optimized out>)
at src/switch_loadable_module.c:1399
#12 0x00007ffff75a9631 in switch_loadable_module_unload_module
(dir=<value optimized out>, fname=0x7ffff006ddd0 "mod_snmp",
force=SWITCH_FALSE, err=<value optimized out>)
at src/switch_loadable_module.c:1052
#13 0x00007fffebe834c5 in reload_function (cmd=0x7ffff006ddd0
"mod_snmp", session=<value optimized out>, stream=0x7fffe70f0db0) at
/usr/src/freeswitch/src/mod/applications/mod_commands/mod_commands.c:1837
#14 0x00007ffff75a7224 in switch_api_execute (cmd=0x7ffff016bc80
"reload", arg=0x7ffff016bc87 "mod_snmp", session=0x0,
stream=0x7fffe70f0db0) at src/switch_loadable_module.c:1810
#15 0x00007ffff7582b9a in switch_console_execute (xcmd=0x7ffff016bc80
"reload", rec=<value optimized out>, istream=0x7fffe70f0db0) at
src/switch_console.c:385
#16 0x00007ffff758443e in switch_console_process (xcmd=0x7ffff027dc90
"reload mod_snmp") at src/switch_console.c:317
#17 0x00007ffff7584631 in console_thread (thread=<value optimized out>,
obj=<value optimized out>) at src/switch_console.c:1042
#18 0x00007ffff7622417 in dummy_worker () from
/usr/local/freeswitch/lib/libfreeswitch.so.1
#19 0x00007ffff6cd2d8c in start_thread () from /lib/libpthread.so.0
#20 0x00007ffff620361d in clone () from /lib/libc.so.6
#21 0x0000000000000000 in ?? ()
5.6
Thread 30 (Thread 0x7fffe8119700 (LWP 27978)):
#0 0x00007ffff61fb683 in select () from /lib/libc.so.6
#1 0x00007fffed706532 in snmp_synch_response_cb (ss=0x7fffe40b0ad0,
pdu=<value optimized out>, response=0x7fffe8118728, pcb=<value optimized
out>) at snmp_client.c:1022
#2 0x00007fffedd99c2a in agentx_close_session (ss=0x7fffe40b0ad0,
why=5) at mibgroup/agentx/client.c:154
#3 0x00007fffedd88483 in subagent_shutdown (majorID=<value optimized
out>, minorID=<value optimized out>, serverarg=<value optimized out>,
clientarg=0x7fffe40b0ad0) at mibgroup/agentx/subagent.c:669
#4 0x00007fffed75196c in snmp_call_callbacks (major=0, minor=2,
caller_arg=0x0) at callback.c:338
#5 0x00007fffed727e87 in snmp_shutdown (type=<value optimized out>) at
snmp_api.c:898
#6 0x00007fffedfc80c2 in mod_snmp_shutdown () at
/usr/src/freeswitch/src/mod/event_handlers/mod_snmp/mod_snmp.c:119
#7 0x00007ffff75a92a0 in do_shutdown (module=0x7fffe40a7ec8,
shutdown=<value optimized out>, unload=<value optimized out>,
fail_if_busy=SWITCH_TRUE, err=<value optimized out>)
at src/switch_loadable_module.c:1399
#8 0x00007ffff75a9631 in switch_loadable_module_unload_module
(dir=<value optimized out>, fname=0x7fffe402f2e0 "mod_snmp",
force=SWITCH_FALSE, err=<value optimized out>)
at src/switch_loadable_module.c:1052
#9 0x00007fffec63c4c5 in reload_function (cmd=0x7fffe402f2e0
"mod_snmp", session=<value optimized out>, stream=0x7fffe8118db0) at
/usr/src/freeswitch/src/mod/applications/mod_commands/mod_commands.c:1837
#10 0x00007ffff75a7224 in switch_api_execute (cmd=0x7fffe4141990
"reload", arg=0x7fffe4141997 "mod_snmp", session=0x0,
stream=0x7fffe8118db0) at src/switch_loadable_module.c:1810
#11 0x00007ffff7582b9a in switch_console_execute (xcmd=0x7fffe4141990
"reload", rec=<value optimized out>, istream=0x7fffe8118db0) at
src/switch_console.c:385
#12 0x00007ffff758443e in switch_console_process (xcmd=0x7fffe4034c20
"reload mod_snmp") at src/switch_console.c:317
#13 0x00007ffff7584631 in console_thread (thread=<value optimized out>,
obj=<value optimized out>) at src/switch_console.c:1042
#14 0x00007ffff7622417 in dummy_worker () from
/usr/local/freeswitch/lib/libfreeswitch.so.1
#15 0x00007ffff6cd2d8c in start_thread () from /lib/libpthread.so.0
#16 0x00007ffff620361d in clone () from /lib/libc.so.6
#17 0x0000000000000000 in ?? ()
In both cases, the thread just hangs there indefinitely.
I would really appreciate somebody more experienced with Net-SNMP taking
a look at the module I've written, and pointing out anything I'm doing
majorly wrong.
Do I need to manually unregister any OID handlers before calling
snmp_shutdown()? Do I need to unregister my custom logging callback
func? Am I using too high a level abstraction, and should I be using
some of the lower level functions, to allow for a greater level of
customization in this instance?
Thanks in advance
Daniel Swarbrick
--
Mit freundlichen Grüßen
Daniel Swarbrick
Lead Engineer
Seventh Signal Ltd. & Co. KG
Weigandufer 45, Büro 115, D-12059 Berlin
Voice: +49 30 60988730
Amtsgericht Charlottenburg HRA 44413 B
Ust.-ID: DE266981999
Geschäftsführer: Michal Bielicki
Persönlich Haftende Gesellschafterin:
Seventh Signal Ltd, 69 Great Hampton St. Birmingham,
B18 6EW, GB, Company Nr.: 06889439
WWW.: http://www.seventhsignal.de
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders