summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c3
-rw-r--r--channels/chan_sip.c9
-rw-r--r--channels/chan_skinny.c3
3 files changed, 7 insertions, 8 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 1df3cf3e8..d19adbef0 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -10771,8 +10771,7 @@ static int set_config(char *config_file, int reload)
} else if (!strcasecmp(v->name, "regcontext")) {
ast_copy_string(regcontext, v->value, sizeof(regcontext));
/* Create context if it doesn't exist already */
- if (!ast_context_find(regcontext))
- ast_context_create(NULL, regcontext, "IAX2");
+ ast_context_find_or_create(NULL, NULL, regcontext, "IAX2");
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 40645214a..a4afae1a9 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -3388,6 +3388,7 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
{
char multi[256];
char *stringp, *ext, *context;
+ struct pbx_find_info q = { .stacklen = 0 };
/* XXX note that global_regcontext is both a global 'enable' flag and
* the name of the global regexten context, if not specified
@@ -3408,11 +3409,12 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
} else {
context = global_regcontext;
}
- if (onoff)
+ if (onoff) {
ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
ast_strdup(peer->name), ast_free_ptr, "SIP");
- else
+ } else if (pbx_find_extension(NULL, NULL, &q, context, ext, 1, NULL, "", E_MATCH)) {
ast_context_remove_extension(context, ext, 1, NULL);
+ }
}
}
@@ -20297,8 +20299,7 @@ static int reload_config(enum channelreloadreason reason)
/* 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");
+ ast_context_find_or_create(NULL, NULL, context, "SIP");
}
ast_copy_string(global_regcontext, v->value, sizeof(global_regcontext));
} else if (!strcasecmp(v->name, "regextenonqualify")) {
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 44d88ae1f..4baa5771a 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -5801,8 +5801,7 @@ static int reload_config(void)
/* 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");
+ ast_context_find_or_create(NULL, NULL, context, "Skinny");
}
ast_copy_string(regcontext, v->value, sizeof(regcontext));
} else if (!strcasecmp(v->name, "dateformat")) {