diff options
author | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-06-19 21:21:15 +0000 |
---|---|---|
committer | mnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-06-19 21:21:15 +0000 |
commit | 8b04fc3fdaeacfee5d91351d697b39f695d3af78 (patch) | |
tree | 40a8605162f48626e4e66bfe60bafe6cf907d9cd | |
parent | 75766a68ffbbbe17cf79d32efbc6483743019f97 (diff) |
Added deadlock protection to try_suggested_sip_codec in chan_sip.c.
Review: https://reviewboard.asterisk.org/r/287/
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@202022 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 78709e422..3999abba0 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3729,8 +3729,20 @@ static void try_suggested_sip_codec(struct sip_pvt *p) int fmt; const char *codec; - codec = pbx_builtin_getvar_helper(p->owner, "SIP_CODEC"); - if (!codec) + while (p->owner && ast_channel_trylock(p->owner)) { + sip_pvt_unlock(p); + sched_yield(); + sip_pvt_lock(p); + } + + if (!p->owner) + return; + + codec = ast_strdupa(S_OR(pbx_builtin_getvar_helper(p->owner, "SIP_CODEC"), "")); + + ast_channel_unlock(p->owner); + + if (ast_strlen_zero(codec)) return; fmt = ast_getformatbyname(codec); |