[asterisk-commits] murf: trunk r89513 - in /trunk: apps/ channels/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Nov 21 17:54:13 CST 2007
Author: murf
Date: Wed Nov 21 17:54:12 2007
New Revision: 89513
URL: http://svn.digium.com/view/asterisk?view=rev&rev=89513
Log:
closes issue #11285, where an unload of a module that creates a dialplan context, causes a crash when you do a 'dialplan show' of that context. This is because the registrar string is defined in the module, and the stale pointer is traversed. The reporter offered a patch that would always strdup the registrar string, which is practical, but I preferred to destroy the created contexts in each module where one is created. That seemed more symmetric. There were only 6 place in asterisk where this is done: chan_sip, chan_iax2, chan_skinny, res_features, app_dial, and app_queue. The two apps destroyed the context, but left the contexts. All is fixed now and unloads should be dialplan friendly.
Modified:
trunk/apps/app_dial.c
trunk/apps/app_queue.c
trunk/channels/chan_iax2.c
trunk/channels/chan_sip.c
trunk/channels/chan_skinny.c
trunk/res/res_features.c
Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_dial.c?view=diff&rev=89513&r1=89512&r2=89513
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Wed Nov 21 17:54:12 2007
@@ -1953,8 +1953,11 @@
res |= ast_unregister_application(rapp);
if ((con = ast_context_find("app_dial_gosub_virtual_context")))
+ {
ast_context_remove_extension2(con, "s", 1, NULL);
-
+ ast_context_destroy(con, "app_dial"); /* leave nothing behind */
+ }
+
return res;
}
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=89513&r1=89512&r2=89513
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Wed Nov 21 17:54:12 2007
@@ -5516,6 +5516,7 @@
if ((con = ast_context_find("app_queue_gosub_virtual_context"))) {
ast_context_remove_extension2(con, "s", 1, NULL);
+ ast_context_destroy(con, "app_queue"); /* leave no trace */
}
clear_and_free_interfaces();
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=89513&r1=89512&r2=89513
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Wed Nov 21 17:54:12 2007
@@ -11400,6 +11400,7 @@
static int __unload_module(void)
{
struct iax2_thread *thread = NULL;
+ struct ast_context *con;
int x;
/* Make sure threads do not hold shared resources when they are canceled */
@@ -11465,7 +11466,11 @@
ao2_ref(peers, -1);
ao2_ref(users, -1);
-
+
+ con = ast_context_find(regcontext);
+ if (con)
+ ast_context_destroy(con, "IAX2");
+
return 0;
}
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=89513&r1=89512&r2=89513
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Nov 21 17:54:12 2007
@@ -555,6 +555,7 @@
* a bridged channel on hold */
static int default_maxcallbitrate; /*!< Maximum bitrate for call */
static struct ast_codec_pref default_prefs; /*!< Default codec prefs */
+static char used_context[AST_MAX_CONTEXT]; /*!< name of automatically created context for unloading */
/*! \brief a place to store all global settings for the sip channel driver */
struct sip_settings {
@@ -18191,6 +18192,7 @@
cleanup_stale_contexts(stringp, oldregcontext);
/* Create contexts if they don't exist already */
while ((context = strsep(&stringp, "&"))) {
+ ast_copy_string(used_context, context, sizeof(used_context));
if (!ast_context_find(context))
ast_context_create(NULL, context,"SIP");
}
@@ -19205,6 +19207,7 @@
static int unload_module(void)
{
struct sip_pvt *p, *pl;
+ struct ast_context *con;
/* First, take us out of the channel type list */
ast_channel_unregister(&sip_tech);
@@ -19274,6 +19277,9 @@
clear_sip_domains();
close(sipsock);
sched_context_destroy(sched);
+ con = ast_context_find(used_context);
+ if (con)
+ ast_context_destroy(con, "SIP");
return 0;
}
Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=89513&r1=89512&r2=89513
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Wed Nov 21 17:54:12 2007
@@ -92,6 +92,7 @@
static int keep_alive = 120;
static char vmexten[AST_MAX_EXTENSION]; /* Voicemail pilot number */
+static char used_context[AST_MAX_EXTENSION]; /* Voicemail pilot number */
static char regcontext[AST_MAX_CONTEXT]; /* Context for auto-extension */
static char date_format[6] = "D-M-Y";
static char version_id[16] = "P002F202";
@@ -5508,6 +5509,7 @@
cleanup_stale_contexts(stringp, oldregcontext);
/* Create contexts if they don't exist already */
while ((context = strsep(&stringp, "&"))) {
+ ast_copy_string(used_context, context, sizeof(used_context));
if (!ast_context_find(context))
ast_context_create(NULL, context, "Skinny");
}
@@ -5705,6 +5707,7 @@
struct skinny_device *d;
struct skinny_line *l;
struct skinny_subchannel *sub;
+ struct ast_context *con;
ast_mutex_lock(&sessionlock);
/* Destroy all the interfaces and free their memory */
@@ -5762,6 +5765,10 @@
if (sched)
sched_context_destroy(sched);
+ con = ast_context_find(used_context);
+ if (con)
+ ast_context_destroy(con, "Skinny");
+
return 0;
}
Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?view=diff&rev=89513&r1=89512&r2=89513
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Wed Nov 21 17:54:12 2007
@@ -3305,6 +3305,7 @@
static int unload_module(void)
{
+ struct ast_context *con;
ast_manager_unregister("ParkedCalls");
ast_manager_unregister("Bridge");
ast_manager_unregister("Park");
@@ -3312,6 +3313,12 @@
ast_unregister_application(parkcall);
ast_unregister_application(app_bridge);
ast_devstate_prov_del("Park");
+ con = ast_context_find(parking_con);
+ if (con)
+ ast_context_destroy(con, registrar);
+ con = ast_context_find(parking_con_dial);
+ if (con)
+ ast_context_destroy(con, registrar);
return ast_unregister_application(parkedcall);
}
More information about the asterisk-commits
mailing list