Hi!

This is my situation.
I use NET-SNMP version 5.4.2.1. My net-snmp subagent is embedded to service 
application running in linux.
Once started, it handles SNMP requests using the table iterator helper and 
works fine.
Also when I stop the snmpd deamon and later restart it, the subagent reconnects 
properly.

And that's the problem:
When I uninitialize the subagent inside my application and later try a restart, 
it fails.
Further SNMP requests addressed to my subagent result in an error ("No such 
name").
Note that in this scenario I do not exit the application that houses the 
subagent. If I do this, everything's fine again, but this is *not* an option.

So the Question is:
How can I gracefully restart the subagent.


I tried several things to shutdown the subagent and clean up.

1) like in the example subagent, only calling
    snmp_shutdown(MY_AGENT_NAME);

When initializing again, i get the messages:
daemon.warn net-snmp[7094]: ignoring extra call to init_agent (2)
daemon.err net-snmp[2918]: netsnmp_assert !"registration != duplicate" failed 
/home_2/releases/rootfs_ipos_rel_2_2_0/build/ROOTFS/app/net-snmp/agent/agent_registry.c:536
 netsnmp_subtree_load()

2) i do also unregister the handler created in the MIB table init function
    netsnmp_unregister_handler(reg);

With this I got rid of the assert.Still, the agent is not started again. 
I tried lots of function calls to unregister/free the stuff created but mostly 
ended up in some bad errors in glibc's free, bad pointers etc.

When i finally call shutdown_agent(), also the "extra call to init_agent" is 
avoided since this clears the init count to zero.
However, I get no message at all! No bad ones, but no good ones neither. 

With extensive logging (-Dregister_mib,agentx), I saw that the master agent 
seems not to be re-initialized when calling all the init functions again. 
The last log messages i get are the ones from uninit:

register_mib: unregistering iso.3.6.1.4.[...]
register_mib: unload(iso.3.6.1.4.[...], [NIL])
agentx/master: send response, stat 0 (req=0x38450af1,trans=0x0,sess=0x7)
agentx_build: packet built okay
agentx/master: handle pdu (req=0x38450af2,trans=0x0,sess=0x7)
agentx/master: close 0x100a3e70, 7
register_mib: unregister_mibs_by_session(0x100b67b0) ctxt "[NIL]"
agentx/master: closed 0x100a3e70, 7 okay
agentx/master: send response, stat 0 (req=0x38450af2,trans=0x0,sess=0x7)
agentx_build: packet built okay
agentx/master: transport disconnect on session 0x100a3e70
agentx/master: close 0x100a3e70, -1
register_mib: unregister_mibs_by_session(0x100a3e70) ctxt ""

Another bad thing is that my application can't find out that this re-init 
failed. There is no error returned from any of the snmp init_ functions.


I searched through the web and the mail archives a lot and found similar 
questions, though no answers at all.
Now I hope someone here can tell me what's wrong, i'd highly appreciate any 
hints!

Thanks, 
Mario
                                          
_________________________________________________________________
Windows 7: Finden Sie den richtigen PC. Erfahren Sie mehr darĂ¼ber.
http://windows.microsoft.com/shop
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to