On Fri, 2009-06-05 at 11:53 +0800, Tewen Hsieh wrote:
> Hi Dave and MF,

Sorry - I am wrong, the 
> Thanks for your help.
> 
> I have changed shoutdown_xxx to deinit_xxx, and it(deinit_xxx) seems to be 
> called when I send -HUP to snmpd to reload config file this time.
> But there's  a strange condition that deinit_xxx is called "twice" when I 
> just send "one" -HUP to snmpd. (I add a printf in deinit_xxx() to know this 
> result)
> I am really confused about this strange condition.
> Do you have any idea about this?

Not really. What is the content of dlmodTable when you see this?

Anyway, I am sorry to say that I am wrong - for a dlopened module a
reconfiguration do indeed look like an unload followed by a load but
there might be spurious calls to the config free functions before the
unload.

/MF

> 
> Thanks,
> 
> 
> 永鈦鑫   iTAS Corporation
> 新竹市水源街75號
> NO. 75,Shuiyuan St., Hsinchu City, Taiwan, R.O.C.
> Tel:03-5716099 Ext.1208
> E-mail:[email protected]
> ----- Original Message ----- 
> From: "Magnus Fromreide" <[email protected]>
> To: "Dave Shield" <[email protected]>
> Cc: "Tewen Hsieh" <[email protected]>; 
> <[email protected]>
> Sent: Wednesday, June 03, 2009 6:14 AM
> Subject: Re: Does "killall -HUP snmpd" unload dynamic module?
> 
> 
> > On Tue, 2009-06-02 at 08:42 +0100, Dave Shield wrote:
> >> 2009/6/2 Tewen Hsieh <[email protected]>:
> >> > If there is malloc( ) in my dynamic module, does it cause any memory 
> >> > leak
> >> > problem when I use "killall -HUP snmpd" to reload config file?
> >>
> >> That depends on your code.
> >>
> >> > Is the dynamic allocated memory freed by OS automatically?
> >>
> >> Only when the agent exits - not when it simply receives a signal.
> >>
> >> > Or I should free it by myself?
> >>
> >> When the agent re-loads the config file, it will call the 'shutdown_xxx'
> >> routine for each module (assuming that the module defines one).
> >> This is where you should release any dynmically allocated resources.
> >
> > This is actually wrong.
> > When the agent reloads the config file the shutdown methods won't be
> > called, they are only called on shutdown or dlmod module unloading but
> > in the latter case it is the deinit_xxx method that is called in older
> > agents (as Dave explains in later messages) and it is still the first
> > tried function in 5.5 even if shutdown_xxx is a better choice unless
> > there is a need to keep dlclose handling separate from shutdown
> > handling..
> >
> > Reconfig is indicated by snmp callbacks - for trunk the following
> > sequnce is valid:
> >
> >     1. A callback is issued with the tags
> >        (SNMP_CALLBACK_APPLICATION,SNMPD_CALLBACK_PRE_UPDATE_CONFIG)
> >     2. The free_config function that calls the cleanup procedures
> >        registered with the configuration handlers are called.
> >     3. A callback indicating that all is cleared is issued with the
> >        tags (SNMP_CALLBACK_LIBRARY,SNMP_CALLBACK_PRE_READ_CONFIG)
> >     4. The configuration file is reread for the normal config items -
> >        note that the pre configuration items are kept ignored here.
> >     5. A callback to indicate that all configuration is read is issued
> >        with the tags
> >        (SNMP_CALLBACK_LIBRARY,SNMP_CALLBACK_POST_READ_CONFIG)
> >
> > /MF
> >
> >> Essentially, 'shutdown_xxx' should undo anything that was set up in
> >> the 'init_xxx' or config parsing routines.
> >>
> >> Dave
> >>
> >> ------------------------------------------------------------------------------
> >> OpenSolaris 2009.06 is a cutting edge operating system for enterprises
> >> looking to deploy the next generation of Solaris that includes the latest
> >> innovations from Sun and the OpenSource community. Download a copy and
> >> enjoy capabilities such as Networking, Storage and Virtualization.
> >> Go to: http://p.sf.net/sfu/opensolaris-get
> >> _______________________________________________
> >> Net-snmp-coders mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
> > 
> 
> 
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
> looking to deploy the next generation of Solaris that includes the latest 
> innovations from Sun and the OpenSource community. Download a copy and 
> enjoy capabilities such as Networking, Storage and Virtualization. 
> Go to: http://p.sf.net/sfu/opensolaris-get
> _______________________________________________
> Net-snmp-coders mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to