summaryrefslogtreecommitdiff
path: root/channels/chan_pjsip.c
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2016-07-21 20:34:44 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-07-21 20:34:44 -0500
commitba2da66bd57ad2f9abb0daa8634e80b7e89c99fd (patch)
tree1daae3399d296646c7bd746e3ee6ed71d4b3f74c /channels/chan_pjsip.c
parent3abf482393be553ac14691887e368434fb7a38f1 (diff)
parent3db468ea9e3154758a965e247adaffdbc158034c (diff)
Merge "chan_pjsip.c: Fix deadlock potential in fax redirection."
Diffstat (limited to 'channels/chan_pjsip.c')
-rw-r--r--channels/chan_pjsip.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 5a341f866..2e87393a6 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -630,16 +630,19 @@ static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_sip_session *se
target_context = S_OR(ast_channel_macrocontext(session->channel), ast_channel_context(session->channel));
- /* We need to unlock the channel here because ast_exists_extension has the
+ /*
+ * We need to unlock the channel here because ast_exists_extension has the
* potential to start and stop an autoservice on the channel. Such action
* is prone to deadlock if the channel is locked.
+ *
+ * ast_async_goto() has its own restriction on not holding the channel lock.
*/
ast_channel_unlock(session->channel);
+ ast_frfree(f);
+ f = &ast_null_frame;
exists = ast_exists_extension(session->channel, target_context, "fax", 1,
S_COR(ast_channel_caller(session->channel)->id.number.valid,
ast_channel_caller(session->channel)->id.number.str, NULL));
- ast_channel_lock(session->channel);
-
if (exists) {
ast_verb(2, "Redirecting '%s' to fax extension due to CNG detection\n",
ast_channel_name(session->channel));
@@ -648,12 +651,11 @@ static struct ast_frame *chan_pjsip_cng_tone_detected(struct ast_sip_session *se
ast_log(LOG_ERROR, "Failed to async goto '%s' into fax extension in '%s'\n",
ast_channel_name(session->channel), target_context);
}
- ast_frfree(f);
- f = &ast_null_frame;
} else {
ast_log(LOG_NOTICE, "FAX CNG detected on '%s' but no fax extension in '%s'\n",
ast_channel_name(session->channel), target_context);
}
+ ast_channel_lock(session->channel);
return f;
}