[asterisk-commits] file: branch file/usecnt-cleanup r54521 - in
/team/file/usecnt-cleanup: chann...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Feb 14 15:33:06 MST 2007
Author: file
Date: Wed Feb 14 16:33:05 2007
New Revision: 54521
URL: http://svn.digium.com/view/asterisk?view=rev&rev=54521
Log:
Add partial automatic unregistering support... so far application and channel unregistering works while CLI unregistering seems to corrupt the memory. Yay!
Modified:
team/file/usecnt-cleanup/channels/chan_local.c
team/file/usecnt-cleanup/main/channel.c
team/file/usecnt-cleanup/main/loader.c
team/file/usecnt-cleanup/main/pbx.c
Modified: team/file/usecnt-cleanup/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/channels/chan_local.c?view=diff&rev=54521&r1=54520&r2=54521
==============================================================================
--- team/file/usecnt-cleanup/channels/chan_local.c (original)
+++ team/file/usecnt-cleanup/channels/chan_local.c Wed Feb 14 16:33:05 2007
@@ -682,8 +682,6 @@
struct local_pvt *p = NULL;
/* First, take us out of the channel loop */
- ast_cli_unregister_multiple(cli_local, sizeof(cli_local) / sizeof(struct ast_cli_entry));
- ast_channel_unregister(&local_tech);
if (!AST_LIST_LOCK(&locals)) {
/* Hangup all interfaces if they have an owner */
AST_LIST_TRAVERSE(&locals, p, list) {
Modified: team/file/usecnt-cleanup/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/main/channel.c?view=diff&rev=54521&r1=54520&r2=54521
==============================================================================
--- team/file/usecnt-cleanup/main/channel.c (original)
+++ team/file/usecnt-cleanup/main/channel.c Wed Feb 14 16:33:05 2007
@@ -416,6 +416,10 @@
AST_LIST_UNLOCK(&channels);
return -1;
}
+
+ if (mod)
+ ast_module_link(mod, AST_MODULE_REGISTERED_CHANNEL, (void*)tech);
+
chan->tech = tech;
chan->module = mod;
AST_LIST_INSERT_HEAD(&backends, chan, list);
@@ -442,6 +446,8 @@
AST_LIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) {
if (chan->tech == tech) {
+ if (chan->module)
+ ast_module_unlink(chan->module, AST_MODULE_REGISTERED_CHANNEL, (void*)tech);
AST_LIST_REMOVE_CURRENT(&backends, list);
free(chan);
if (option_verbose > 1)
Modified: team/file/usecnt-cleanup/main/loader.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/main/loader.c?view=diff&rev=54521&r1=54520&r2=54521
==============================================================================
--- team/file/usecnt-cleanup/main/loader.c (original)
+++ team/file/usecnt-cleanup/main/loader.c Wed Feb 14 16:33:05 2007
@@ -53,6 +53,8 @@
#include "asterisk/lock.h"
#include "asterisk/pbx.h"
+#include "asterisk/cli.h"
+
#ifdef DLFCNCOMPAT
#include "asterisk/dlfcn-compat.h"
#else
@@ -477,6 +479,24 @@
ast_log(LOG_WARNING, "** Dangerous **: Unloading resource anyway, at user request\n");
}
}
+ /* Check module registration linkages */
+ if (!AST_LIST_EMPTY(&mod->links)) {
+ struct ast_module_link *link = NULL;
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&mod->links, link, list) {
+ /* Unregister linkage on behalf of the module */
+ if (link->registered == AST_MODULE_REGISTERED_APPLICATION)
+ res = ast_unregister_application((const char*)link->data);
+ else if (link->registered == AST_MODULE_REGISTERED_CHANNEL)
+ ast_channel_unregister((const struct ast_channel_tech *)link->data);
+ else if (link->registered == AST_MODULE_REGISTERED_CLI)
+ res = ast_cli_unregister((struct ast_cli_entry*)link->data);
+ /* Remove linkage */
+ AST_LIST_REMOVE_CURRENT(&mod->links, list);
+ free(link);
+ /* Handle error from unregister process */
+ }
+ AST_LIST_TRAVERSE_SAFE_END
+ }
}
if (!error)
@@ -959,5 +979,16 @@
void ast_module_unlink(struct ast_module *mod, enum ast_module_registered registered, void *data)
{
+ struct ast_module_link *link = NULL;
+
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&mod->links, link, list) {
+ if (link->registered == registered && link->data == data) {
+ AST_LIST_REMOVE_CURRENT(&mod->links, list);
+ free(link);
+ break;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END
+
return;
}
Modified: team/file/usecnt-cleanup/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/main/pbx.c?view=diff&rev=54521&r1=54520&r2=54521
==============================================================================
--- team/file/usecnt-cleanup/main/pbx.c (original)
+++ team/file/usecnt-cleanup/main/pbx.c Wed Feb 14 16:33:05 2007
@@ -2864,7 +2864,7 @@
strcpy(tmp->name, app);
if (mod)
- ast_module_link(mod, AST_MODULE_REGISTERED_APPLICATION, tmp);
+ ast_module_link(mod, AST_MODULE_REGISTERED_APPLICATION, (void*)app);
tmp->module = mod;
tmp->execute = execute;
More information about the asterisk-commits
mailing list