From: Matthew Nicholson Date: Fri, 19 Jun 2009 21:08:11 +0000 (+0000) Subject: Added deadlock protection to try_suggested_sip_codec in chan_sip.c. X-Git-Tag: 1.6.1.3-rc1~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8a03ddfddd4f70a9bc40df0225312ab4544fef2;p=thirdparty%2Fasterisk.git Added deadlock protection to try_suggested_sip_codec in chan_sip.c. Review: https://reviewboard.asterisk.org/r/287/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@202008 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index e24f391860..74fff4f900 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -5395,8 +5395,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);