On Tue, 19 Oct 2004 17:07:56 -0200 Ivens wrote:
IP> Robert Story (Coders) wrote:
IP> > On Tue, 19 Oct 2004 14:58:30 -0200 Ivens wrote:
IP> > IP> I'm embedding an agentx sub-agent in my application and now I would
IP> > IP> like to make my sub-agent became a master agent when a master agent
IP> > IP> is not present.
IP> > IP> > Interesting idea, but I'm not sure it will work. The double call to init
IP> > will probably cause unexpected results.
IP> IP> What if I shut everything down before restarting as an agent? Would IP> calling snmp_shutdown() solve the problem?
I was hoping you wouldn't ask that.
In theory, yes, that should work. However, since the agent exists when shutting down, not a whole lot of work has gone into testing and working out the kinks of snmp_shutdown. We've always relied on the OS to clean up memory on exit, so the shutdown routine probably doesn't free everything. I think, i fyou look at the code, it is actually ifdef'd out because of a double-free that nobody has tracked down yet.
Depending on your configuration and OS, it might work for you. If not, and you don't mind getting dirty with code, fire up a debugger and dig into the code. It would be great if someone had the time to clean up that code and send us some patches.
I didn't dig deep into the code but I ran my application on Valgrind to try to detect memory problems and the only thing I got was an invalid free() in snmp_shutdown(). Below is Valgrind output with the backtrace:
==31937== Invalid free() / delete / delete[] ==31937== at 0x1B902460: free (vg_replace_malloc.c:153) ==31937== by 0x1BBABDC7: clear_callback (callback.c:297) ==31937== by 0x1BB7FEC6: snmp_shutdown (snmp_api.c:848) ==31937== by 0x8051770: snmpAgentThread (snmp.c:1031) ==31937== Address 0x1BE85768 is 0 bytes inside a block of size 220 free'd ==31937== at 0x1B902460: free (vg_replace_malloc.c:153) ==31937== by 0x1BB8191C: snmp_free_session (snmp_api.c:1693) ==31937== by 0x1BB81AF4: snmp_sess_close (snmp_api.c:1773) ==31937== by 0x1BB81C72: snmp_close (snmp_api.c:1803) ==31937== by 0x1BA87174: subagent_shutdown (subagent.c:612) ==31937== by 0x1BBAB916: snmp_call_callbacks (callback.c:189) ==31937== by 0x1BB7FE99: snmp_shutdown (snmp_api.c:837) ==31937== by 0x8051770: snmpAgentThread (snmp.c:1031)
I'm not sending a patch because I don't know the best way to solve this. I've been working with net-snmp for a short time and I don't know much about the inner works of it.
Can anyone take a look at this?
-- Ivens Porto OSE - Open Systems Engineering http://www.ose.com.br Phone: (55) 34 - 3214-5995 Fax: (55) 34 - 3214-5994 Cel: (55) 34 - 8816-9942
------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Net-snmp-coders mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
