]> git.ipfire.org Git - thirdparty/asterisk.git/commit
func_lock: fix multiple-channel-grant problems.
authorJaco Kroon <jaco@uls.co.za>
Fri, 18 Dec 2020 19:06:20 +0000 (21:06 +0200)
committerJoshua Colp <jcolp@sangoma.com>
Wed, 6 Jan 2021 18:04:07 +0000 (12:04 -0600)
commitc7975009565a5729a223cefc012c13d5973cc53b
treec0e25db74cb2a25d767e6b9be96712fd2b1f69c3
parent4e038c1eaae70605b6ef67a93c5ffea46a2d7c60
func_lock: fix multiple-channel-grant problems.

Under contention it becomes possible that multiple channels will be told
they successfully obtained the lock, which is a bug.  Please refer

ASTERISK-29217

This introduces a couple of changes.

1.  Replaces requesters ao2 container with simple counter (we don't
    really care who is waiting for the lock, only how many).  This is
    updated undex ->mutex to prevent memory access races.
2.  Correct semantics for ast_cond_timedwait() as described in
    pthread_cond_broadcast(3P) is used (multiple threads can be released
    on a single _signal()).
3.  Module unload races are taken care of and memory properly cleaned
    up.

Change-Id: I6f68b5ec82ff25b2909daf6e4d19ca864a463e29
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
funcs/func_lock.c