]> git.ipfire.org Git - thirdparty/asterisk.git/commit
lock: Add named lock capability 91/2991/1
authorGeorge Joseph <george.joseph@fairview5.com>
Fri, 1 Apr 2016 01:04:29 +0000 (19:04 -0600)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 7 Jun 2016 23:15:58 +0000 (18:15 -0500)
commit880d5021415610b9c240f7fbc4047380d7a1ad87
tree64136c53727b3c3093099ec1b94e350e31003f00
parenta81feefde94f5d8c89397ab18f94f0900d080f98
lock:  Add named lock capability

Locking some objects like sorcery objects can be tricky because the underlying
ao2 object may not be the same for all callers.  For instance, two threads that
call ast_sorcery_retrieve_by_id on the same aor name might actually get 2
different ao2 objects if the underlying wizard had to rehydrate the aor from a
database. Locking one ao2 object doesn't have any effect on the other even if
those objects had locks in the first place.

Named locks allow access control by keyspace and key strings.  Now an "aor"
named "1000" can be locked and any other thread attempting to lock "aor" "1000"
will wait regardless of whether the underlying ao2 object is the same or not.
Mutex and rwlocks are supported.

This capability will initially be used to lock an aor when multiple threads may
be attempting to prune expired contacts from it.

Change-Id: If258c0b7f92b02d07243ce70e535821a1ea7fb45
include/asterisk/_private.h
include/asterisk/named_locks.h [new file with mode: 0644]
main/asterisk.c
main/named_locks.c [new file with mode: 0644]
tests/test_named_lock.c [new file with mode: 0644]