]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Unlock the channel before calling update_queue.
authorMatthew Nicholson <mnicholson@digium.com>
Fri, 12 Aug 2011 19:01:27 +0000 (19:01 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Fri, 12 Aug 2011 19:01:27 +0000 (19:01 +0000)
Holding the channel lock when calling update_queue which attempts to lock the
queue lock can cause a deadlock. This deadlock involves the following chain:

1. hold chan lock -> wait queue lock
2. hold queue lock -> wait agent list lock
3. hold agent list lock -> wait chan list lock
4. hold chan list lock -> wait chan lock

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

apps/app_queue.c

index a1274c2e6c47ef3bb96ebb8c0bfe4d77df293aa1..4b146387ae42db89467eefdb0f4289e5ac18e361 100644 (file)
@@ -5065,8 +5065,11 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                        if ((tds = ast_channel_datastore_find(qe->chan, &queue_transfer_info, NULL))) { 
                                ast_channel_datastore_remove(qe->chan, tds);
                        }
+                       ast_channel_unlock(qe->chan);
                        update_queue(qe->parent, member, callcompletedinsl, (time(NULL) - callstart));
                } else {
+                       ast_channel_unlock(qe->chan);
+
                        /* We already logged the TRANSFER on the queue_log, but we still need to send the AgentComplete event */
                        send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER);
                }
@@ -5074,7 +5077,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                if (transfer_ds) {
                        ast_datastore_free(transfer_ds);
                }
-               ast_channel_unlock(qe->chan);
                ast_hangup(peer);
                res = bridge ? bridge : 1;
                ao2_ref(member, -1);