]> 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:48 +0000 (16:17 -0600)
commit241359870502d39f813887a706fb6404bdfc51cb
tree02866d8feacea90f0dbd7d72823f0edb3bbf6186
parent98d1537c1eab8334416238091632025325297319
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