Asterisk - The Open Source Telephony Project
21.4.1
|
Functions implementing astobj2 objects. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/astobj2.h"
#include "astobj2_private.h"
#include "astobj2_container_private.h"
#include "asterisk/cli.h"
#include "asterisk/paths.h"
Go to the source code of this file.
Data Structures | |
struct | __priv_data |
struct | ao2_lock_priv |
struct | ao2_lockobj_priv |
struct | ao2_rwlock_priv |
struct | ao2_weakproxy_notification |
struct | astobj2 |
struct | astobj2_lock |
struct | astobj2_lockobj |
struct | astobj2_rwlock |
Macros | |
#define | __INTERNAL_OBJ_CHECK(user_data, file, line, func) |
convert from a pointer _p to a user-defined object More... | |
#define | AO2_MAGIC 0xa70b123 |
#define | AO2_WEAK 0xa70b122 |
#define | ast_log ast_log_safe |
#define | DEBUG_THREADS_LOOSE_ABI |
#define | EXCESSIVE_REF_COUNT 100000 |
#define | EXTERNAL_OBJ(_p) ((_p) == NULL ? NULL : (_p)->user_data) |
convert from a pointer _p to an astobj2 object More... | |
#define | INTERNAL_OBJ(user_data) (struct astobj2 *) ((char *) user_data - sizeof(struct astobj2)) |
#define | INTERNAL_OBJ_CHECK(user_data) __INTERNAL_OBJ_CHECK(user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | INTERNAL_OBJ_LOCKOBJ(user_data) ((struct astobj2_lockobj *) (((char *) (user_data)) - sizeof(struct astobj2_lockobj))) |
#define | INTERNAL_OBJ_MUTEX(user_data) ((struct astobj2_lock *) (((char *) (user_data)) - sizeof(struct astobj2_lock))) |
#define | INTERNAL_OBJ_RWLOCK(user_data) ((struct astobj2_rwlock *) (((char *) (user_data)) - sizeof(struct astobj2_rwlock))) |
#define | IS_AO2_MAGIC_BAD(p) (AO2_MAGIC != (p->priv_data.magic | 1)) |
Functions | |
enum ao2_lock_req | __adjust_lock (void *user_data, enum ao2_lock_req lock_how, int keep_stronger) |
void * | __ao2_alloc (size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, const char *tag, const char *file, int line, const char *func) |
void * | __ao2_alloc_with_lockobj (size_t data_size, ao2_destructor_fn destructor_fn, void *lockobj, const char *tag, const char *file, int line, const char *func) |
void | __ao2_cleanup (void *obj) |
void | __ao2_cleanup_debug (void *obj, const char *tag, const char *file, int line, const char *function) |
void * | __ao2_get_weakproxy (void *obj, const char *tag, const char *file, int line, const char *func) |
int | __ao2_lock (void *user_data, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var) |
Lock an object. More... | |
int | __ao2_ref (void *user_data, int delta, const char *tag, const char *file, int line, const char *func) |
int | __ao2_trylock (void *user_data, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var) |
Try locking– (don't block if fail) More... | |
int | __ao2_unlock (void *user_data, const char *file, const char *func, int line, const char *var) |
Unlock an object. More... | |
void * | __ao2_weakproxy_alloc (size_t data_size, ao2_destructor_fn destructor_fn, const char *tag, const char *file, int line, const char *func) |
void * | __ao2_weakproxy_get_object (void *weakproxy, int flags, const char *tag, const char *file, int line, const char *func) |
int | __ao2_weakproxy_ref_object (void *weakproxy, int delta, int flags, const char *tag, const char *file, int line, const char *func) |
int | __ao2_weakproxy_set_object (void *weakproxy, void *obj, int flags, const char *tag, const char *file, int line, const char *func) |
void * | ao2_object_get_lockaddr (void *user_data) |
Return the mutex lock address of an object. More... | |
unsigned int | ao2_options_get (void *obj) |
Retrieve the ao2 options used to create the object. More... | |
int | ao2_weakproxy_subscribe (void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags) |
Request notification when weakproxy points to NULL. More... | |
int | ao2_weakproxy_unsubscribe (void *weakproxy, ao2_weakproxy_notification_cb destroyed_cb, void *data, int flags) |
Remove notification of real object destruction. More... | |
static void | astobj2_cleanup (void) |
int | astobj2_init (void) |
static void * | internal_ao2_alloc (size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, void *lockobj, const char *tag, const char *file, int line, const char *func) |
int | internal_is_ao2_object (void *user_data) |
void | log_bad_ao2 (void *user_data, const char *file, int line, const char *func) |
Variables | |
static FILE * | ref_log |
#define __INTERNAL_OBJ_CHECK | ( | user_data, | |
file, | |||
line, | |||
func | |||
) |
convert from a pointer _p to a user-defined object
Definition at line 171 of file astobj2.c.
Referenced by __ao2_lock(), __ao2_trylock(), and __ao2_unlock().
#define EXTERNAL_OBJ | ( | _p | ) | ((_p) == NULL ? NULL : (_p)->user_data) |
void __ao2_cleanup | ( | void * | obj | ) |
gcc attribute(cleanup()) functions
Definition at line 677 of file astobj2.c.
References ao2_ref.
Referenced by agent_request_exec(), ast_ari_bridges_set_video_source(), bridge_agent_hold_push(), dial_bridge_after_cb(), and parking_set_duration().
int __ao2_lock | ( | void * | a, |
enum ao2_lock_req | lock_how, | ||
const char * | file, | ||
const char * | func, | ||
int | line, | ||
const char * | var | ||
) |
Lock an object.
a | A pointer to the object we want to lock. |
lock_how,file,func,line,var |
Definition at line 222 of file astobj2.c.
References __INTERNAL_OBJ_CHECK, AO2_ALLOC_OPT_LOCK_MASK, AO2_ALLOC_OPT_LOCK_MUTEX, AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_LOCK_RWLOCK, AO2_LOCK_REQ_MUTEX, AO2_LOCK_REQ_RDLOCK, AO2_LOCK_REQ_WRLOCK, ast_atomic_fetchadd_int(), __priv_data::lockused, ao2_rwlock_priv::num_lockers, and __priv_data::options.
int __ao2_trylock | ( | void * | a, |
enum ao2_lock_req | lock_how, | ||
const char * | file, | ||
const char * | func, | ||
int | line, | ||
const char * | var | ||
) |
Try locking– (don't block if fail)
a | A pointer to the object we want to lock. |
lock_how,file,func,line,var |
Definition at line 342 of file astobj2.c.
References __INTERNAL_OBJ_CHECK, AO2_ALLOC_OPT_LOCK_MASK, AO2_ALLOC_OPT_LOCK_MUTEX, AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_LOCK_RWLOCK, AO2_LOCK_REQ_MUTEX, AO2_LOCK_REQ_RDLOCK, AO2_LOCK_REQ_WRLOCK, ast_atomic_fetchadd_int(), __priv_data::lockused, ao2_rwlock_priv::num_lockers, and __priv_data::options.
int __ao2_unlock | ( | void * | a, |
const char * | file, | ||
const char * | func, | ||
int | line, | ||
const char * | var | ||
) |
Unlock an object.
a | A pointer to the object we want unlock. |
file,func,line,var |
Definition at line 288 of file astobj2.c.
References __INTERNAL_OBJ_CHECK, AO2_ALLOC_OPT_LOCK_MASK, AO2_ALLOC_OPT_LOCK_MUTEX, AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_LOCK_RWLOCK, ast_atomic_fetchadd_int(), ao2_rwlock_priv::num_lockers, and __priv_data::options.
void* ao2_object_get_lockaddr | ( | void * | obj | ) |
Return the mutex lock address of an object.
[in] | obj | A pointer to the object we want. |
This function comes in handy mainly for debugging locking situations, where the locking trace code reports the lock address, this allows you to correlate against object address, to match objects to reported locks.
Definition at line 476 of file astobj2.c.
References AO2_ALLOC_OPT_LOCK_MASK, AO2_ALLOC_OPT_LOCK_MUTEX, and __priv_data::options.
Referenced by ast_rtp_ice_turn_request(), control_wait(), db_sync_thread(), ice_reset_session(), and stasis_subscription_join().
unsigned int ao2_options_get | ( | void * | obj | ) |
Retrieve the ao2 options used to create the object.
obj | pointer to the (user-defined part) of an object. |
Definition at line 781 of file astobj2.c.
References __priv_data::options.
int ao2_weakproxy_subscribe | ( | void * | weakproxy, |
ao2_weakproxy_notification_cb | cb, | ||
void * | data, | ||
int | flags | ||
) |
Request notification when weakproxy points to NULL.
weakproxy | The weak object |
cb | Procedure to call when no real object is associated |
data | Passed to cb |
flags | OBJ_NOLOCK to avoid locking weakproxy. |
0 | Success |
-1 | Failure |
Definition at line 934 of file astobj2.c.
References ast_calloc, AST_LIST_INSERT_HEAD, and __priv_data::weakptr.
int ao2_weakproxy_unsubscribe | ( | void * | weakproxy, |
ao2_weakproxy_notification_cb | cb, | ||
void * | data, | ||
int | flags | ||
) |
Remove notification of real object destruction.
weakproxy | The weak object |
cb | Callback to remove from destroy notification list |
data | Data pointer to match |
flags | OBJ_NOLOCK to avoid locking weakproxy. OBJ_MULTIPLE to remove all copies of the same cb / data pair. |
0 | cb / data pair not found, nothing removed. |
-1 | Failure due to invalid parameters. |
Definition at line 973 of file astobj2.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, and OBJ_MULTIPLE.
int astobj2_init | ( | void | ) |
Provided by astobj2.c
Definition at line 1169 of file astobj2.c.
References ast_cli_register_multiple, and ast_register_cleanup().