diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-03-23 00:56:36 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-03-23 00:56:36 +0000 |
commit | 0930211404075b03b77d7b819a27b66cbdb027b4 (patch) | |
tree | 95fbb387f57bbd8bc039939002d07c91f4618857 | |
parent | 6f9bf4b16180ac9327c42811f3928b0bf7868ca0 (diff) |
Hold owner lock when changing codecs
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2529 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | channels/chan_iax2.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 5b17fa464..404f32ad7 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -4948,11 +4948,21 @@ retryowner: iaxs[fr.callno]->owner->nativeformats = iaxs[fr.callno]->peerformat; if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Format for call is %s\n", ast_getformatname(iaxs[fr.callno]->owner->nativeformats)); - /* Setup read/write formats properly. */ - if (iaxs[fr.callno]->owner->writeformat) - ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat); - if (iaxs[fr.callno]->owner->readformat) - ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat); +retryowner2: + if (ast_mutex_trylock(&iaxs[fr.callno]->owner->lock)) { + ast_mutex_unlock(&iaxsl[fr.callno]); + usleep(1); + ast_mutex_lock(&iaxsl[fr.callno]); + if (iaxs[fr.callno] && iaxs[fr.callno]->owner) goto retryowner2; + } + + if (iaxs[fr.callno] && iaxs[fr.callno]->owner) { + /* Setup read/write formats properly. */ + if (iaxs[fr.callno]->owner->writeformat) + ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat); + if (iaxs[fr.callno]->owner->readformat) + ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat); + } } } ast_mutex_lock(&dpcache_lock); |