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