34 #define NAMED_LOCKS_BUCKETS 101
47 static
void named_locks_shutdown(
void)
49 ao2_cleanup(named_locks);
55 NAMED_LOCKS_BUCKETS, named_lock_proxy_hash_fn, NULL, named_lock_proxy_cmp_fn);
65 static void named_lock_proxy_cb(
void *weakproxy,
void *data)
70 struct ast_named_lock *__ast_named_lock_get(
const char *filename,
int lineno,
const char *func,
75 int keylen = strlen(keyspace) + strlen(key) + 2;
78 sprintf(concat_key,
"%s-%s", keyspace, key);
80 ao2_lock(named_locks);
82 __PRETTY_FUNCTION__, filename, lineno, func);
85 ao2_unlock(named_locks);
90 proxy = ao2_t_weakproxy_alloc(
sizeof(*proxy) + keylen, NULL, concat_key);
95 lock = __ao2_alloc(
sizeof(*lock) + keylen, NULL, lock_type, concat_key, filename, lineno, func);
102 goto failure_cleanup;
106 goto failure_cleanup;
109 strcpy(proxy->key, concat_key);
111 ao2_unlock(named_locks);
112 ao2_t_ref(proxy, -1,
"Release allocation reference");
117 ao2_unlock(named_locks);
#define ao2_weakproxy_set_object(weakproxy, obj, flags)
Associate weakproxy with obj.
Asterisk main include file. File version handling, generic pbx functions.
AO2_STRING_FIELD_HASH_FN(transport_monitor, key)
Hashing function for struct transport_monitor.
The arg parameter is a search key, but is not an object.
Assume that the ao2_container is already locked.
AO2_STRING_FIELD_CMP_FN(transport_monitor, key)
Comparison function for struct transport_monitor.
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
int ao2_weakproxy_subscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags)
Request notification when weakproxy points to NULL.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
ast_named_lock_type
Which type of lock to request.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
#define ao2_unlink(container, obj)
Remove an object from a container.
Prototypes for public functions only of internal interest,.
int ast_named_locks_init(void)
unsigned int ao2_options_get(void *obj)
Retrieve the ao2 options used to create the object.