[Asterisk-Dev] Module unloading
Michael Sandee
ms at zeelandnet.nl
Sun Jul 4 01:45:20 MST 2004
When writing a module which does some magic on unload_module() I ran
into some trouble...
In contrary to what include/asterisk/module.h says, unload_module() does
not get called during exit, only when unload is called from the CLI.
//! Cleanup all module structures, sockets, etc
/*!
* This is called at exit. Any registrations and memory allocations need
* to be unregistered and free'd here. Nothing else will do these for
you (until exit).
* Return 0 on success, or other than 0 if there is a problem.
*/
int unload_module(void);
Asterisk needs you to specifically register an exit function to be
called in the quit_handler().
static void mymodule_atexit(void)
{
// do magic stuff
}
at the end of load_module:
ast_register_atexit(mymodule_atexit);
at the beginning of unload_module:
ast_unregister_atexit(mymodule_atexit);
Comments on this are welcome.
Some other application developers ran into this problem so I suggest the
comments in module.h are being changed... Some applications depend on it.
Michael
More information about the asterisk-dev
mailing list