diff --git a/apps/app_dial.c b/apps/app_dial.c index a4d9557785cf8abc99929153d3d1a56857720938..714c38a852f2a36d05f6d2da0f4f6ddb8de52529 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1953,8 +1953,11 @@ static int unload_module(void) 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; } diff --git a/apps/app_queue.c b/apps/app_queue.c index 382982351cd4d63452b98578372aafeae2ff1624..dc84542478932c46a37daed80c45f442bb787658 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -5516,6 +5516,7 @@ static int unload_module(void) 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(); diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 6e2a0ab968189795e953d2200c59d02a12c984ed..725d25758ff5fcd20317c3c4fa70fa315ce71e8b 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -11400,6 +11400,7 @@ static struct ast_cli_entry cli_iax2[] = { 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 @@ static int __unload_module(void) ao2_ref(peers, -1); ao2_ref(users, -1); - + + con = ast_context_find(regcontext); + if (con) + ast_context_destroy(con, "IAX2"); + return 0; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 4d651cf8622d287f3703c16c375a74cef3bd63bb..b81ac3f30f7ba7f7eee7590155309b629c907550 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; } diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 7640ef34192a1b1dad4ad48adb49ed4e2c5be208..0422a23923577a5650999248e14a186abdf1cf66 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -92,6 +92,7 @@ enum skinny_codecs { 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 @@ static int reload_config(void) 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 @@ static int unload_module(void) 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 @@ static int unload_module(void) if (sched) sched_context_destroy(sched); + con = ast_context_find(used_context); + if (con) + ast_context_destroy(con, "Skinny"); + return 0; } diff --git a/res/res_features.c b/res/res_features.c index 8bb8e5f381f2a03da3a2891395e21418d1c8b1c2..31ce64b1a74224980fecb30566a590bc57538549 100644 --- a/res/res_features.c +++ b/res/res_features.c @@ -3305,6 +3305,7 @@ static int load_module(void) 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 @@ static int unload_module(void) 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); }