diff options
author | Steve Murphy <murf@digium.com> | 2007-11-21 23:54:12 +0000 |
---|---|---|
committer | Steve Murphy <murf@digium.com> | 2007-11-21 23:54:12 +0000 |
commit | 86476c607f9b636046b39c7913edf75b850f6517 (patch) | |
tree | 0dc51f470ca68136426e22f709f308185e6121c2 /channels/chan_sip.c | |
parent | 7e8835e0d79b129fe07a5f1a67aee35548e616cd (diff) |
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.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89513 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 4d651cf86..b81ac3f30 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -555,6 +555,7 @@ static char default_mohsuggest[MAX_MUSICCLASS]; /*!< Global setting for moh c * 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 @@ static int reload_config(enum channelreloadreason reason) 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 load_module(void) 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 @@ static int unload_module(void) clear_sip_domains(); close(sipsock); sched_context_destroy(sched); + con = ast_context_find(used_context); + if (con) + ast_context_destroy(con, "SIP"); return 0; } |