Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
|
Macros | |
#define | ast_named_lock_get(lock_type, keyspace, key) |
Geta named lock handle. More... | |
#define | ast_named_lock_put(lock) ao2_cleanup(lock) |
Put a named lock handle away. More... | |
Enumerations | |
enum | ast_named_lock_type { AST_NAMED_LOCK_TYPE_MUTEX = AO2_ALLOC_OPT_LOCK_MUTEX , AST_NAMED_LOCK_TYPE_RWLOCK = AO2_ALLOC_OPT_LOCK_RWLOCK } |
Which type of lock to request. More... | |
Functions | |
struct ast_named_lock * | __ast_named_lock_get (const char *filename, int lineno, const char *func, enum ast_named_lock_type lock_type, const char *keyspace, const char *key) |
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 placeNamed locks allow access control by name. Now an aor named "1000" can be locked and any other thread attempting to lock the aor named "1000" will wait regardless of whether the underlying ao2 object is the same or not.To use a named lock: Call ast_named_lock_get with the appropriate keyspace and key. Use the standard ao2 lock/unlock functions as needed. Call ao2_cleanup when you're finished with it.
#define ast_named_lock_get | ( | lock_type, | |
keyspace, | |||
key | |||
) |
Geta named lock handle.
lock_type | One of ast_named_lock_type |
keyspace | |
key |
A | pointer to an ast_named_lock structure |
NULL | on error |
Definition at line 83 of file named_locks.h.
#define ast_named_lock_put | ( | lock | ) | ao2_cleanup(lock) |
Put a named lock handle away.
lock | The pointer to the ast_named_lock structure returned by ast_named_lock_get |
Definition at line 93 of file named_locks.h.
enum ast_named_lock_type |
Which type of lock to request.
Enumerator | |
---|---|
AST_NAMED_LOCK_TYPE_MUTEX | Request a named mutex. |
AST_NAMED_LOCK_TYPE_RWLOCK | Request a named read/write lock. |
Definition at line 57 of file named_locks.h.
struct ast_named_lock * __ast_named_lock_get | ( | const char * | filename, |
int | lineno, | ||
const char * | func, | ||
enum ast_named_lock_type | lock_type, | ||
const char * | keyspace, | ||
const char * | key | ||
) |
Definition at line 70 of file named_locks.c.
References __ao2_alloc(), __ao2_weakproxy_find(), AO2_ALLOC_OPT_LOCK_MASK, ao2_cleanup, ao2_link_flags, ao2_lock, ao2_options_get(), ao2_t_ref, ao2_t_weakproxy_alloc, ao2_unlock, ao2_weakproxy_set_object, ao2_weakproxy_subscribe(), ast_alloca, ast_assert, named_lock_proxy::key, lock, named_lock_proxy_cb(), named_locks, NULL, OBJ_NOLOCK, and OBJ_SEARCH_KEY.