]> git.ipfire.org Git - thirdparty/asterisk.git/commit
taskprocessor: Fix race condition between unreferencing and finding. 26/1226/1
authorJoshua Colp <jcolp@digium.com>
Sat, 29 Aug 2015 15:36:35 +0000 (12:36 -0300)
committerMark Michelson <mmichelson@digium.com>
Tue, 8 Sep 2015 22:11:37 +0000 (17:11 -0500)
commit0901a82adbecdb2621efb481472aedc218f8fa4c
treee53eaa6d8e569404c185abc5c543688911ad3e9e
parent5b06b6f1d319aa9649b88721ae29c334ef365533
taskprocessor: Fix race condition between unreferencing and finding.

When unreferencing a taskprocessor its reference count is checked
to determine if it should be unlinked from the taskprocessors
container and its listener shut down. In between the time when the
reference count is checked and unlinking it is possible for
another thread to jump in, find it, and get a reference to it. If
the thread then uses the taskprocessor it may find that it is not
in the state it expects.

This change locks the taskprocessors container during almost the
entire unreference operation to ensure that any other thread which
may attempt to find the taskprocessor has to wait.

ASTERISK-25295

Change-Id: Icb842db82fe1cf238da55df92e95938a4419377c
(cherry picked from commit a676ba2aad5525926ae31b8317b95ae52cbbabbb)
main/taskprocessor.c