]> git.ipfire.org Git - thirdparty/asterisk.git/commit
app_queue: Fix deadlock between update and show queues
authorGeorge Joseph <gjoseph@digium.com>
Wed, 11 Nov 2020 14:55:22 +0000 (07:55 -0700)
committerKevin Harwell <kharwell@digium.com>
Thu, 12 Nov 2020 22:17:18 +0000 (16:17 -0600)
commit8d8c9db6187216215cd516e76151583509c23470
tree03398ca88e98e5369c36f1002c9b51d8815b8b0c
parent3366956139de7a96d776385ea61211d7be985ff2
app_queue: Fix deadlock between update and show queues

Operations that update queues when shared_lastcall is set lock the
queue in question, then have to lock the queues container to find the
other queues with the same member. On the other hand, __queues_show
(which is called by both the CLI and AMI) does the reverse. It locks
the queues container, then iterates over the queues locking each in
turn to display them.  This creates a deadlock.

* Moved queue print logic from __queues_show to a separate function
  that can be called for a single queue.

* Updated __queues_show so it doesn't need to lock or traverse
  the queues container to show a single queue.

* Updated __queues_show to snap a copy of the queues container and iterate
  over that instead of locking the queues container and iterating over
  it while locked.  This prevents us from having to hold both the
  container lock and the queue locks at the same time.  This also
  allows us to sort the queue entries.

ASTERISK-29155

Change-Id: I78d4dc36728c2d7bc187b97d82673fc77f2bcf41
apps/app_queue.c