]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix handling of when a pvt disappears. Properly return the pvt locked
authorRussell Bryant <russell@russellbryant.com>
Mon, 7 Jul 2008 22:41:48 +0000 (22:41 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 7 Jul 2008 22:41:48 +0000 (22:41 +0000)
and don't hold the pvt lock while destroying the ast_channel.

(closes issue #13014)
Reported by: jpgrayson
Patches:
      chan_iax2_ast_iax2_new2.patch uploaded by jpgrayson (license 492)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@128795 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c

index e548222352f7c1b3bd3cc6c1426dc72c75958a78..70c8d60721ef65c93a22efd2f0a44e6704a22b13 100644 (file)
@@ -3766,11 +3766,13 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
        ast_mutex_unlock(&iaxsl[callno]);
        tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "IAX2/%s-%d", i->host, i->callno);
        ast_mutex_lock(&iaxsl[callno]);
-       if (!iaxs[callno]) {
+       if (i != iaxs[callno]) {
                if (tmp) {
+                       /* unlock and relock iaxsl[callno] to preserve locking order */
+                       ast_mutex_unlock(&iaxsl[callno]);
                        ast_channel_free(tmp);
+                       ast_mutex_lock(&iaxsl[callno]);
                }
-               ast_mutex_unlock(&iaxsl[callno]);
                return NULL;
        }