Cleanup unload calls

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1850 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2003-12-09 23:55:17 +00:00
parent 23cfe10d94
commit 2f69b332d8
8 changed files with 390 additions and 360 deletions

View File

@@ -5330,6 +5330,33 @@ static struct ast_switch iax_switch =
matchmore: iax_matchmore,
};
static int __unload_module(void)
{
int x;
/* Cancel the network thread, close the net socket */
pthread_cancel(netthreadid);
pthread_join(netthreadid, NULL);
close(netsocket);
for (x=0;x<AST_IAX_MAX_CALLS;x++)
if (iaxs[x])
iax_destroy(x);
ast_manager_unregister( "IAXpeers" );
ast_cli_unregister(&cli_show_users);
ast_cli_unregister(&cli_show_channels);
ast_cli_unregister(&cli_show_peers);
ast_cli_unregister(&cli_set_jitter);
ast_cli_unregister(&cli_show_stats);
ast_cli_unregister(&cli_show_cache);
ast_unregister_switch(&iax_switch);
delete_users();
return 0;
}
int unload_module()
{
return __unload_module();
}
int load_module(void)
{
char *config = "iax.conf";
@@ -5379,7 +5406,7 @@ int load_module(void)
if (ast_channel_register(type, tdesc, iax_capability, iax_request)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
unload_module();
__unload_module();
return -1;
}
@@ -5426,28 +5453,6 @@ char *description()
return desc;
}
int unload_module()
{
int x;
/* Cancel the network thread, close the net socket */
pthread_cancel(netthreadid);
pthread_join(netthreadid, NULL);
close(netsocket);
for (x=0;x<AST_IAX_MAX_CALLS;x++)
if (iaxs[x])
iax_destroy(x);
ast_manager_unregister( "IAXpeers" );
ast_cli_unregister(&cli_show_users);
ast_cli_unregister(&cli_show_channels);
ast_cli_unregister(&cli_show_peers);
ast_cli_unregister(&cli_set_jitter);
ast_cli_unregister(&cli_show_stats);
ast_cli_unregister(&cli_show_cache);
ast_unregister_switch(&iax_switch);
delete_users();
return 0;
}
int usecount()
{
int res;