summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorMatthew Nicholson <mnicholson@digium.com>2009-06-18 17:41:09 +0000
committerMatthew Nicholson <mnicholson@digium.com>2009-06-18 17:41:09 +0000
commit21ad428d0d8735cda1d0930b38a6719824929af7 (patch)
tree13906f5712ade6fee78ab2fb57d8ae474868ab04 /channels/chan_sip.c
parentdcfe69ec6454cecae1d6c25bbaf33e26a531b3ff (diff)
Added deadlock protection to try_suggested_sip_codec in chan_sip.c.
Review: https://reviewboard.asterisk.org/r/285/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@201717 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 6795ce2ee..97168e7ee 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6076,6 +6076,14 @@ static void try_suggested_sip_codec(struct sip_pvt *p)
{
int fmt;
const char *codec;
+ struct ast_channel* chan;
+
+ chan = ast_channel_ref(p->owner);
+ while (ast_channel_trylock(chan)) {
+ sip_pvt_unlock(p);
+ usleep(1);
+ sip_pvt_lock(p);
+ }
if (p->outgoing_call) {
codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC_OUTBOUND");
@@ -6083,7 +6091,12 @@ static void try_suggested_sip_codec(struct sip_pvt *p)
codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC");
}
- if (!codec)
+ codec = ast_strdupa(S_OR(codec, ""));
+
+ ast_channel_unlock(chan);
+ chan = ast_channel_unref(chan);
+
+ if (ast_strlen_zero(codec))
return;
fmt = ast_getformatbyname(codec);