#include "asterisk.h"#include "asterisk/_private.h"#include "asterisk/astobj2.h"#include "asterisk/utils.h"#include "asterisk/cli.h"#include <execinfo.h>

Go to the source code of this file.
Data Structures | |
| struct | __priv_data |
| struct | ao2_container |
| struct | astobj2 |
| struct | bucket |
| struct | bucket_list |
Defines | |
| #define | AO2_MAGIC 0xa570b123 |
| #define | EXTERNAL_OBJ(_p) ((_p) == NULL ? NULL : (_p)->user_data) |
| convert from a pointer _p to an astobj2 object | |
| #define | N1 20 |
| #define | REF_FILE "/tmp/refs" |
Enumerations | |
| enum | ao2_callback_type { DEFAULT, WITH_DATA } |
Functions | |
| static void * | __ao2_alloc (size_t data_size, ao2_destructor_fn destructor_fn, const char *file, int line, const char *funcname) |
| static void * | __ao2_callback (struct ao2_container *c, const enum search_flags flags, void *cb_fn, void *arg, void *data, enum ao2_callback_type type, char *tag, char *file, int line, const char *funcname) |
| static struct ao2_container * | __ao2_container_alloc (struct ao2_container *c, const unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn) |
| static struct ao2_container * | __ao2_container_alloc (struct ao2_container *c, const uint n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn) |
| static void * | __ao2_iterator_next (struct ao2_iterator *a, struct bucket_list **q) |
| static struct bucket_list * | __ao2_link (struct ao2_container *c, void *user_data, const char *file, int line, const char *func) |
| static int | __ao2_ref (void *user_data, const int delta) |
| void * | _ao2_alloc (size_t data_size, ao2_destructor_fn destructor_fn) |
| void * | _ao2_alloc_debug (size_t data_size, ao2_destructor_fn destructor_fn, char *tag, const char *file, int line, const char *funcname, int ref_debug) |
| void * | _ao2_callback (struct ao2_container *c, const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg) |
| void * | _ao2_callback_data (struct ao2_container *c, const enum search_flags flags, ao2_callback_data_fn *cb_fn, void *arg, void *data) |
| void * | _ao2_callback_data_debug (struct ao2_container *c, const enum search_flags flags, ao2_callback_data_fn *cb_fn, void *arg, void *data, char *tag, char *file, int line, const char *funcname) |
| void * | _ao2_callback_debug (struct ao2_container *c, const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, char *tag, char *file, int line, const char *funcname) |
| struct ao2_container * | _ao2_container_alloc (const unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn) |
| struct ao2_container * | _ao2_container_alloc_debug (const unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn, char *tag, char *file, int line, const char *funcname, int ref_debug) |
| void * | _ao2_find (struct ao2_container *c, void *arg, enum search_flags flags) |
| void * | _ao2_find_debug (struct ao2_container *c, void *arg, enum search_flags flags, char *tag, char *file, int line, const char *funcname) |
| void * | _ao2_iterator_next (struct ao2_iterator *a) |
| void * | _ao2_iterator_next_debug (struct ao2_iterator *a, char *tag, char *file, int line, const char *funcname) |
| void * | _ao2_link (struct ao2_container *c, void *user_data) |
| void * | _ao2_link_debug (struct ao2_container *c, void *user_data, char *tag, char *file, int line, const char *funcname) |
| int | _ao2_lock (void *user_data, const char *file, const char *func, int line, const char *var) |
| int | _ao2_ref (void *user_data, const int delta) |
| int | _ao2_ref_debug (void *user_data, const int delta, char *tag, char *file, int line, const char *funcname) |
| int | _ao2_trylock (void *user_data, const char *file, const char *func, int line, const char *var) |
| void * | _ao2_unlink (struct ao2_container *c, void *user_data) |
| void * | _ao2_unlink_debug (struct ao2_container *c, void *user_data, char *tag, char *file, int line, const char *funcname) |
| int | _ao2_unlock (void *user_data, const char *file, const char *func, int line, const char *var) |
| void | ao2_bt (void) |
| int | ao2_container_count (struct ao2_container *c) |
| Returns the number of elements in a container. | |
| void | ao2_iterator_destroy (struct ao2_iterator *i) |
| Destroy a container iterator. | |
| struct ao2_iterator | ao2_iterator_init (struct ao2_container *c, int flags) |
| Create an iterator for a container. | |
| int | ao2_lock (void *user_data) |
| Lock an object. | |
| int | ao2_match_by_addr (void *user_data, void *arg, int flags) |
| another convenience function is a callback that matches on address | |
| void * | ao2_object_get_lockaddr (void *obj) |
| Return the lock address of an object. | |
| int | ao2_trylock (void *user_data) |
| Try locking-- (don't block if fail). | |
| int | ao2_unlock (void *user_data) |
| Unlock an object. | |
| int | astobj2_init (void) |
| static int | cb_true (void *user_data, void *arg, int flags) |
| special callback that matches all | |
| static int | cb_true_data (void *user_data, void *arg, void *data, int flags) |
| similar to cb_true, but is an ao2_callback_data_fn instead | |
| static int | cd_cb (void *obj, void *arg, int flag) |
| static int | cd_cb_debug (void *obj, void *arg, int flag) |
| static void | container_destruct (void *c) |
| static void | container_destruct_debug (void *c) |
| static int | hash_zero (const void *user_obj, const int flags) |
| always zero hash function | |
| static struct astobj2 * | INTERNAL_OBJ (void *user_data) |
| convert from a pointer _p to a user-defined object | |
| #define AO2_MAGIC 0xa570b123 |
| #define EXTERNAL_OBJ | ( | _p | ) | ((_p) == NULL ? NULL : (_p)->user_data) |
convert from a pointer _p to an astobj2 object
Definition at line 133 of file astobj2.c.
Referenced by __ao2_alloc(), __ao2_callback(), and __ao2_iterator_next().
| #define N1 20 |
Referenced by ao2_bt().
| #define REF_FILE "/tmp/refs" |
| enum ao2_callback_type |
| static void* __ao2_alloc | ( | size_t | data_size, | |
| ao2_destructor_fn | destructor_fn, | |||
| const char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) | [static] |
Definition at line 347 of file astobj2.c.
References __ast_calloc(), AO2_MAGIC, ast_atomic_fetchadd_int(), ast_calloc, ast_mutex_init(), __priv_data::data_size, __priv_data::destructor_fn, EXTERNAL_OBJ, __priv_data::lock, __priv_data::magic, astobj2::priv_data, and __priv_data::ref_counter.
Referenced by _ao2_alloc(), and _ao2_alloc_debug().
00348 { 00349 /* allocation */ 00350 struct astobj2 *obj; 00351 00352 if (data_size < sizeof(void *)) 00353 data_size = sizeof(void *); 00354 00355 #if defined(__AST_DEBUG_MALLOC) 00356 obj = __ast_calloc(1, sizeof(*obj) + data_size, file, line, funcname); 00357 #else 00358 obj = ast_calloc(1, sizeof(*obj) + data_size); 00359 #endif 00360 00361 if (obj == NULL) 00362 return NULL; 00363 00364 ast_mutex_init(&obj->priv_data.lock); 00365 obj->priv_data.magic = AO2_MAGIC; 00366 obj->priv_data.data_size = data_size; 00367 obj->priv_data.ref_counter = 1; 00368 obj->priv_data.destructor_fn = destructor_fn; /* can be NULL */ 00369 00370 #ifdef AO2_DEBUG 00371 ast_atomic_fetchadd_int(&ao2.total_objects, 1); 00372 ast_atomic_fetchadd_int(&ao2.total_mem, data_size); 00373 ast_atomic_fetchadd_int(&ao2.total_refs, 1); 00374 #endif 00375 00376 /* return a pointer to the user data */ 00377 return EXTERNAL_OBJ(obj); 00378 }
| static void * __ao2_callback | ( | struct ao2_container * | c, | |
| const enum search_flags | flags, | |||
| void * | cb_fn, | |||
| void * | arg, | |||
| void * | data, | |||
| enum ao2_callback_type | type, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) | [static] |
Browse the container using different stategies accoding the flags.
Definition at line 645 of file astobj2.c.
References _ao2_ref(), _ao2_ref_debug(), ao2_lock(), ao2_unlock(), ast_atomic_fetchadd_int(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), bucket_list::astobj, ao2_container::buckets, cb_true(), cb_true_data(), CMP_MATCH, CMP_STOP, ao2_container::elements, bucket_list::entry, EXTERNAL_OBJ, free, ao2_container::hash_fn, INTERNAL_OBJ(), last, LOG_WARNING, match(), ao2_container::n_buckets, OBJ_CONTINUE, OBJ_MULTIPLE, OBJ_NODATA, OBJ_POINTER, OBJ_UNLINK, ao2_container::version, and WITH_DATA.
Referenced by _ao2_callback(), _ao2_callback_data(), _ao2_callback_data_debug(), and _ao2_callback_debug().
00648 { 00649 int i, start, last; /* search boundaries */ 00650 void *ret = NULL; 00651 ao2_callback_fn *cb_default = NULL; 00652 ao2_callback_data_fn *cb_withdata = NULL; 00653 00654 if (INTERNAL_OBJ(c) == NULL) /* safety check on the argument */ 00655 return NULL; 00656 00657 if ((flags & (OBJ_MULTIPLE | OBJ_NODATA)) == OBJ_MULTIPLE) { 00658 ast_log(LOG_WARNING, "multiple data return not implemented yet (flags %x)\n", flags); 00659 return NULL; 00660 } 00661 00662 /* override the match function if necessary */ 00663 if (cb_fn == NULL) { /* if NULL, match everything */ 00664 if (type == WITH_DATA) { 00665 cb_withdata = cb_true_data; 00666 } else { 00667 cb_default = cb_true; 00668 } 00669 } else { 00670 /* We do this here to avoid the per object casting penalty (even though 00671 that is probably optimized away anyway. */ 00672 if (type == WITH_DATA) { 00673 cb_withdata = cb_fn; 00674 } else { 00675 cb_default = cb_fn; 00676 } 00677 } 00678 00679 /* 00680 * XXX this can be optimized. 00681 * If we have a hash function and lookup by pointer, 00682 * run the hash function. Otherwise, scan the whole container 00683 * (this only for the time being. We need to optimize this.) 00684 */ 00685 if ((flags & OBJ_POINTER)) /* we know hash can handle this case */ 00686 start = i = c->hash_fn(arg, flags & OBJ_POINTER) % c->n_buckets; 00687 else /* don't know, let's scan all buckets */ 00688 start = i = -1; /* XXX this must be fixed later. */ 00689 00690 /* determine the search boundaries: i..last-1 */ 00691 if (i < 0) { 00692 start = i = 0; 00693 last = c->n_buckets; 00694 } else if ((flags & OBJ_CONTINUE)) { 00695 last = c->n_buckets; 00696 } else { 00697 last = i + 1; 00698 } 00699 00700 ao2_lock(c); /* avoid modifications to the content */ 00701 00702 for (; i < last ; i++) { 00703 /* scan the list with prev-cur pointers */ 00704 struct bucket_list *cur; 00705 00706 AST_LIST_TRAVERSE_SAFE_BEGIN(&c->buckets[i], cur, entry) { 00707 int match = (CMP_MATCH | CMP_STOP); 00708 00709 if (type == WITH_DATA) { 00710 match &= cb_withdata(EXTERNAL_OBJ(cur->astobj), arg, data, flags); 00711 } else { 00712 match &= cb_default(EXTERNAL_OBJ(cur->astobj), arg, flags); 00713 } 00714 00715 /* we found the object, performing operations according flags */ 00716 if (match == 0) { /* no match, no stop, continue */ 00717 continue; 00718 } else if (match == CMP_STOP) { /* no match but stop, we are done */ 00719 i = last; 00720 break; 00721 } 00722 /* we have a match (CMP_MATCH) here */ 00723 if (!(flags & OBJ_NODATA)) { /* if must return the object, record the value */ 00724 /* it is important to handle this case before the unlink */ 00725 ret = EXTERNAL_OBJ(cur->astobj); 00726 if (tag) 00727 _ao2_ref_debug(ret, 1, tag, file, line, funcname); 00728 else 00729 _ao2_ref(ret, 1); 00730 } 00731 00732 if (flags & OBJ_UNLINK) { /* must unlink */ 00733 struct bucket_list *x = cur; 00734 00735 /* we are going to modify the container, so update version */ 00736 ast_atomic_fetchadd_int(&c->version, 1); 00737 AST_LIST_REMOVE_CURRENT(entry); 00738 /* update number of elements and version */ 00739 ast_atomic_fetchadd_int(&c->elements, -1); 00740 if (tag) 00741 _ao2_ref_debug(EXTERNAL_OBJ(x->astobj), -1, tag, file, line, funcname); 00742 else 00743 _ao2_ref(EXTERNAL_OBJ(x->astobj), -1); 00744 free(x); /* free the link record */ 00745 } 00746 00747 if ((match & CMP_STOP) || (flags & OBJ_MULTIPLE) == 0) { 00748 /* We found the only match we need */ 00749 i = last; /* force exit from outer loop */ 00750 break; 00751 } 00752 if (!(flags & OBJ_NODATA)) { 00753 #if 0 /* XXX to be completed */ 00754 /* 00755 * This is the multiple-return case. We need to link 00756 * the object in a list. The refcount is already increased. 00757 */ 00758 #endif 00759 } 00760 } 00761 AST_LIST_TRAVERSE_SAFE_END; 00762 00763 if (ret) { 00764 /* This assumes OBJ_MULTIPLE with !OBJ_NODATA is still not implemented */ 00765 break; 00766 } 00767 00768 if (i == c->n_buckets - 1 && (flags & OBJ_POINTER) && (flags & OBJ_CONTINUE)) { 00769 /* Move to the beginning to ensure we check every bucket */ 00770 i = -1; 00771 last = start; 00772 } 00773 } 00774 ao2_unlock(c); 00775 return ret; 00776 }
| static struct ao2_container* __ao2_container_alloc | ( | struct ao2_container * | c, | |
| const unsigned int | n_buckets, | |||
| ao2_hash_fn * | hash_fn, | |||
| ao2_callback_fn * | cmp_fn | |||
| ) | [static, read] |
Definition at line 467 of file astobj2.c.
References ast_atomic_fetchadd_int(), ao2_container::cmp_fn, ao2_container::hash_fn, hash_zero(), ao2_container::n_buckets, and ao2_container::version.
00469 { 00470 /* XXX maybe consistency check on arguments ? */ 00471 /* compute the container size */ 00472 00473 if (!c) 00474 return NULL; 00475 00476 c->version = 1; /* 0 is a reserved value here */ 00477 c->n_buckets = n_buckets; 00478 c->hash_fn = hash_fn ? hash_fn : hash_zero; 00479 c->cmp_fn = cmp_fn; 00480 00481 #ifdef AO2_DEBUG 00482 ast_atomic_fetchadd_int(&ao2.total_containers, 1); 00483 #endif 00484 00485 return c; 00486 }
| static struct ao2_container* __ao2_container_alloc | ( | struct ao2_container * | c, | |
| const uint | n_buckets, | |||
| ao2_hash_fn * | hash_fn, | |||
| ao2_callback_fn * | cmp_fn | |||
| ) | [static, read] |
Referenced by _ao2_container_alloc(), and _ao2_container_alloc_debug().
| static void * __ao2_iterator_next | ( | struct ao2_iterator * | a, | |
| struct bucket_list ** | q | |||
| ) | [static] |
Definition at line 846 of file astobj2.c.
References AO2_ITERATOR_DONTLOCK, ao2_lock(), AST_LIST_NEXT, AST_LIST_TRAVERSE, bucket_list::astobj, ao2_iterator::bucket, ao2_container::buckets, ao2_iterator::c, ao2_iterator::c_version, bucket_list::entry, EXTERNAL_OBJ, ao2_iterator::flags, INTERNAL_OBJ(), ao2_container::n_buckets, ao2_iterator::obj, bucket_list::version, ao2_iterator::version, and ao2_container::version.
Referenced by _ao2_iterator_next(), and _ao2_iterator_next_debug().
00847 { 00848 int lim; 00849 struct bucket_list *p = NULL; 00850 void *ret = NULL; 00851 00852 *q = NULL; 00853 00854 if (INTERNAL_OBJ(a->c) == NULL) 00855 return NULL; 00856 00857 if (!(a->flags & AO2_ITERATOR_DONTLOCK)) 00858 ao2_lock(a->c); 00859 00860 /* optimization. If the container is unchanged and 00861 * we have a pointer, try follow it 00862 */ 00863 if (a->c->version == a->c_version && (p = a->obj) ) { 00864 if ( (p = AST_LIST_NEXT(p, entry)) ) 00865 goto found; 00866 /* nope, start from the next bucket */ 00867 a->bucket++; 00868 a->version = 0; 00869 a->obj = NULL; 00870 } 00871 00872 lim = a->c->n_buckets; 00873 00874 /* Browse the buckets array, moving to the next 00875 * buckets if we don't find the entry in the current one. 00876 * Stop when we find an element with version number greater 00877 * than the current one (we reset the version to 0 when we 00878 * switch buckets). 00879 */ 00880 for (; a->bucket < lim; a->bucket++, a->version = 0) { 00881 /* scan the current bucket */ 00882 AST_LIST_TRAVERSE(&a->c->buckets[a->bucket], p, entry) { 00883 if (p->version > a->version) 00884 goto found; 00885 } 00886 } 00887 00888 found: 00889 if (p) { 00890 a->version = p->version; 00891 a->obj = p; 00892 a->c_version = a->c->version; 00893 ret = EXTERNAL_OBJ(p->astobj); 00894 /* inc refcount of returned object */ 00895 *q = p; 00896 } 00897 00898 return ret; 00899 }
| static struct bucket_list * __ao2_link | ( | struct ao2_container * | c, | |
| void * | user_data, | |||
| const char * | file, | |||
| int | line, | |||
| const char * | func | |||
| ) | [static, read] |
Definition at line 536 of file astobj2.c.
References ao2_lock(), ast_atomic_fetchadd_int(), ast_calloc, AST_LIST_INSERT_TAIL, bucket_list::astobj, INTERNAL_OBJ(), OBJ_POINTER, and bucket_list::version.
Referenced by _ao2_link(), and _ao2_link_debug().
00537 { 00538 int i; 00539 /* create a new list entry */ 00540 struct bucket_list *p; 00541 struct astobj2 *obj = INTERNAL_OBJ(user_data); 00542 00543 if (obj == NULL) 00544 return NULL; 00545 00546 if (INTERNAL_OBJ(c) == NULL) 00547 return NULL; 00548 00549 p = ast_calloc(1, sizeof(*p)); 00550 if (!p) 00551 return NULL; 00552 00553 i = abs(c->hash_fn(user_data, OBJ_POINTER)); 00554 00555 ao2_lock(c); 00556 i %= c->n_buckets; 00557 p->astobj = obj; 00558 p->version = ast_atomic_fetchadd_int(&c->version, 1); 00559 AST_LIST_INSERT_TAIL(&c->buckets[i], p, entry); 00560 ast_atomic_fetchadd_int(&c->elements, 1); 00561 00562 /* the last two operations (ao2_ref, ao2_unlock) must be done by the calling func */ 00563 return p; 00564 }
| static int __ao2_ref | ( | void * | user_data, | |
| const int | delta | |||
| ) | [static] |
Definition at line 298 of file astobj2.c.
References ast_atomic_fetchadd_int(), ast_log(), ast_mutex_destroy(), __priv_data::data_size, __priv_data::destructor_fn, free, INTERNAL_OBJ(), __priv_data::lock, LOG_ERROR, astobj2::priv_data, and __priv_data::ref_counter.
Referenced by _ao2_ref(), and _ao2_ref_debug().
00299 { 00300 struct astobj2 *obj = INTERNAL_OBJ(user_data); 00301 int current_value; 00302 int ret; 00303 00304 if (obj == NULL) 00305 return -1; 00306 00307 /* if delta is 0, just return the refcount */ 00308 if (delta == 0) 00309 return (obj->priv_data.ref_counter); 00310 00311 /* we modify with an atomic operation the reference counter */ 00312 ret = ast_atomic_fetchadd_int(&obj->priv_data.ref_counter, delta); 00313 current_value = ret + delta; 00314 00315 #ifdef AO2_DEBUG 00316 ast_atomic_fetchadd_int(&ao2.total_refs, delta); 00317 #endif 00318 00319 /* this case must never happen */ 00320 if (current_value < 0) 00321 ast_log(LOG_ERROR, "refcount %d on object %p\n", current_value, user_data); 00322 00323 if (current_value <= 0) { /* last reference, destroy the object */ 00324 if (obj->priv_data.destructor_fn != NULL) { 00325 obj->priv_data.destructor_fn(user_data); 00326 } 00327 00328 ast_mutex_destroy(&obj->priv_data.lock); 00329 #ifdef AO2_DEBUG 00330 ast_atomic_fetchadd_int(&ao2.total_mem, - obj->priv_data.data_size); 00331 ast_atomic_fetchadd_int(&ao2.total_objects, -1); 00332 #endif 00333 /* for safety, zero-out the astobj2 header and also the 00334 * first word of the user-data, which we make sure is always 00335 * allocated. */ 00336 memset(obj, '\0', sizeof(struct astobj2 *) + sizeof(void *) ); 00337 free(obj); 00338 } 00339 00340 return ret; 00341 }
| void* _ao2_alloc | ( | size_t | data_size, | |
| ao2_destructor_fn | destructor_fn | |||
| ) |
Definition at line 401 of file astobj2.c.
References __ao2_alloc().
Referenced by _ao2_container_alloc().
00402 { 00403 return __ao2_alloc(data_size, destructor_fn, __FILE__, __LINE__, __FUNCTION__); 00404 }
| void* _ao2_alloc_debug | ( | size_t | data_size, | |
| ao2_destructor_fn | destructor_fn, | |||
| char * | tag, | |||
| const char * | file, | |||
| int | line, | |||
| const char * | funcname, | |||
| int | ref_debug | |||
| ) |
Definition at line 380 of file astobj2.c.
References __ao2_alloc(), and REF_FILE.
Referenced by _ao2_container_alloc_debug(), and _moh_class_malloc().
00382 { 00383 /* allocation */ 00384 void *obj; 00385 FILE *refo = ref_debug ? fopen(REF_FILE,"a") : NULL; 00386 00387 obj = __ao2_alloc(data_size, destructor_fn, file, line, funcname); 00388 00389 if (obj == NULL) 00390 return NULL; 00391 00392 if (refo) { 00393 fprintf(refo, "%p =1 %s:%d:%s (%s)\n", obj, file, line, funcname, tag); 00394 fclose(refo); 00395 } 00396 00397 /* return a pointer to the user data */ 00398 return obj; 00399 }
| void* _ao2_callback | ( | struct ao2_container * | c, | |
| const enum search_flags | flags, | |||
| ao2_callback_fn * | cb_fn, | |||
| void * | arg | |||
| ) |
Definition at line 786 of file astobj2.c.
References __ao2_callback(), and DEFAULT.
Referenced by _ao2_find(), _ao2_unlink(), and container_destruct().
00788 { 00789 return __ao2_callback(c,flags, cb_fn, arg, NULL, DEFAULT, NULL, NULL, 0, NULL); 00790 }
| void* _ao2_callback_data | ( | struct ao2_container * | c, | |
| const enum search_flags | flags, | |||
| ao2_callback_data_fn * | cb_fn, | |||
| void * | arg, | |||
| void * | data | |||
| ) |
Definition at line 800 of file astobj2.c.
References __ao2_callback(), and WITH_DATA.
00802 { 00803 return __ao2_callback(c, flags, cb_fn, arg, data, WITH_DATA, NULL, NULL, 0, NULL); 00804 }
| void* _ao2_callback_data_debug | ( | struct ao2_container * | c, | |
| const enum search_flags | flags, | |||
| ao2_callback_data_fn * | cb_fn, | |||
| void * | arg, | |||
| void * | data, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) |
Definition at line 792 of file astobj2.c.
References __ao2_callback(), and WITH_DATA.
00796 { 00797 return __ao2_callback(c, flags, cb_fn, arg, data, WITH_DATA, tag, file, line, funcname); 00798 }
| void* _ao2_callback_debug | ( | struct ao2_container * | c, | |
| const enum search_flags | flags, | |||
| ao2_callback_fn * | cb_fn, | |||
| void * | arg, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) |
Definition at line 778 of file astobj2.c.
References __ao2_callback(), and DEFAULT.
Referenced by _ao2_find_debug(), _ao2_unlink_debug(), and container_destruct_debug().
00782 { 00783 return __ao2_callback(c,flags, cb_fn, arg, NULL, DEFAULT, tag, file, line, funcname); 00784 }
| struct ao2_container* _ao2_container_alloc | ( | const unsigned int | n_buckets, | |
| ao2_hash_fn * | hash_fn, | |||
| ao2_callback_fn * | cmp_fn | |||
| ) | [read] |
Definition at line 501 of file astobj2.c.
References __ao2_container_alloc(), _ao2_alloc(), and container_destruct().
00503 { 00504 /* XXX maybe consistency check on arguments ? */ 00505 /* compute the container size */ 00506 00507 size_t container_size = sizeof(struct ao2_container) + n_buckets * sizeof(struct bucket); 00508 struct ao2_container *c = _ao2_alloc(container_size, container_destruct); 00509 00510 return __ao2_container_alloc(c, n_buckets, hash_fn, cmp_fn); 00511 }
| struct ao2_container* _ao2_container_alloc_debug | ( | const unsigned int | n_buckets, | |
| ao2_hash_fn * | hash_fn, | |||
| ao2_callback_fn * | cmp_fn, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname, | |||
| int | ref_debug | |||
| ) | [read] |
Definition at line 488 of file astobj2.c.
References __ao2_container_alloc(), _ao2_alloc_debug(), and container_destruct_debug().
00491 { 00492 /* XXX maybe consistency check on arguments ? */ 00493 /* compute the container size */ 00494 size_t container_size = sizeof(struct ao2_container) + n_buckets * sizeof(struct bucket); 00495 struct ao2_container *c = _ao2_alloc_debug(container_size, container_destruct_debug, tag, file, line, funcname, ref_debug); 00496 00497 return __ao2_container_alloc(c, n_buckets, hash_fn, cmp_fn); 00498 }
| void* _ao2_find | ( | struct ao2_container * | c, | |
| void * | arg, | |||
| enum search_flags | flags | |||
| ) |
Definition at line 814 of file astobj2.c.
References _ao2_callback(), and ao2_container::cmp_fn.
Referenced by _get_mohbyname().
00815 { 00816 return _ao2_callback(c, flags, c->cmp_fn, arg); 00817 }
| void* _ao2_find_debug | ( | struct ao2_container * | c, | |
| void * | arg, | |||
| enum search_flags | flags, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) |
the find function just invokes the default callback with some reasonable flags.
Definition at line 809 of file astobj2.c.
References _ao2_callback_debug(), and ao2_container::cmp_fn.
Referenced by _get_mohbyname().
00810 { 00811 return _ao2_callback_debug(c, flags, c->cmp_fn, arg, tag, file, line, funcname); 00812 }
| void* _ao2_iterator_next | ( | struct ao2_iterator * | a | ) |
Definition at line 919 of file astobj2.c.
References __ao2_iterator_next(), _ao2_ref(), AO2_ITERATOR_DONTLOCK, ao2_unlock(), ao2_iterator::c, and ao2_iterator::flags.
00920 { 00921 struct bucket_list *p = NULL; 00922 void *ret = NULL; 00923 00924 ret = __ao2_iterator_next(a, &p); 00925 00926 if (p) { 00927 /* inc refcount of returned object */ 00928 _ao2_ref(ret, 1); 00929 } 00930 00931 if (!(a->flags & AO2_ITERATOR_DONTLOCK)) 00932 ao2_unlock(a->c); 00933 00934 return ret; 00935 }
| void* _ao2_iterator_next_debug | ( | struct ao2_iterator * | a, | |
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) |
Definition at line 901 of file astobj2.c.
References __ao2_iterator_next(), _ao2_ref_debug(), AO2_ITERATOR_DONTLOCK, ao2_unlock(), ao2_iterator::c, and ao2_iterator::flags.
00902 { 00903 struct bucket_list *p; 00904 void *ret = NULL; 00905 00906 ret = __ao2_iterator_next(a, &p); 00907 00908 if (p) { 00909 /* inc refcount of returned object */ 00910 _ao2_ref_debug(ret, 1, tag, file, line, funcname); 00911 } 00912 00913 if (!(a->flags & AO2_ITERATOR_DONTLOCK)) 00914 ao2_unlock(a->c); 00915 00916 return ret; 00917 }
| void* _ao2_link | ( | struct ao2_container * | c, | |
| void * | user_data | |||
| ) |
Definition at line 577 of file astobj2.c.
References __ao2_link(), _ao2_ref(), and ao2_unlock().
00578 { 00579 struct bucket_list *p = __ao2_link(c, user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__); 00580 00581 if (p) { 00582 _ao2_ref(user_data, +1); 00583 ao2_unlock(c); 00584 } 00585 return p; 00586 }
| void* _ao2_link_debug | ( | struct ao2_container * | c, | |
| void * | user_data, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) |
Definition at line 566 of file astobj2.c.
References __ao2_link(), _ao2_ref_debug(), and ao2_unlock().
00567 { 00568 struct bucket_list *p = __ao2_link(c, user_data, file, line, funcname); 00569 00570 if (p) { 00571 _ao2_ref_debug(user_data, +1, tag, file, line, funcname); 00572 ao2_unlock(c); 00573 } 00574 return p; 00575 }
| int _ao2_lock | ( | void * | user_data, | |
| const char * | file, | |||
| const char * | func, | |||
| int | line, | |||
| const char * | var | |||
| ) |
Definition at line 167 of file astobj2.c.
References ast_atomic_fetchadd_int(), ast_mutex_lock(), INTERNAL_OBJ(), __priv_data::lock, and astobj2::priv_data.
00168 { 00169 struct astobj2 *p = INTERNAL_OBJ(user_data); 00170 00171 if (p == NULL) 00172 return -1; 00173 00174 #ifdef AO2_DEBUG 00175 ast_atomic_fetchadd_int(&ao2.total_locked, 1); 00176 #endif 00177 00178 #ifndef DEBUG_THREADS 00179 return ast_mutex_lock(&p->priv_data.lock); 00180 #else 00181 return __ast_pthread_mutex_lock(file, line, func, var, &p->priv_data.lock); 00182 #endif 00183 }
| int _ao2_ref | ( | void * | user_data, | |
| const int | delta | |||
| ) |
Definition at line 288 of file astobj2.c.
References __ao2_ref(), and INTERNAL_OBJ().
Referenced by __ao2_callback(), _ao2_iterator_next(), _ao2_link(), and cd_cb().
00289 { 00290 struct astobj2 *obj = INTERNAL_OBJ(user_data); 00291 00292 if (obj == NULL) 00293 return -1; 00294 00295 return __ao2_ref(user_data, delta); 00296 }
| int _ao2_ref_debug | ( | void * | user_data, | |
| const int | delta, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) |
Definition at line 268 of file astobj2.c.
References __ao2_ref(), __priv_data::destructor_fn, INTERNAL_OBJ(), astobj2::priv_data, __priv_data::ref_counter, and REF_FILE.
Referenced by __ao2_callback(), _ao2_iterator_next_debug(), _ao2_link_debug(), and cd_cb_debug().
00269 { 00270 struct astobj2 *obj = INTERNAL_OBJ(user_data); 00271 00272 if (obj == NULL) 00273 return -1; 00274 00275 if (delta != 0) { 00276 FILE *refo = fopen(REF_FILE,"a"); 00277 fprintf(refo, "%p %s%d %s:%d:%s (%s) [@%d]\n", user_data, (delta<0? "":"+"), delta, file, line, funcname, tag, obj->priv_data.ref_counter); 00278 fclose(refo); 00279 } 00280 if (obj->priv_data.ref_counter + delta == 0 && obj->priv_data.destructor_fn != NULL) { /* this isn't protected with lock; just for o/p */ 00281 FILE *refo = fopen(REF_FILE,"a"); 00282 fprintf(refo, "%p **call destructor** %s:%d:%s (%s)\n", user_data, file, line, funcname, tag); 00283 fclose(refo); 00284 } 00285 return __ao2_ref(user_data, delta); 00286 }
| int _ao2_trylock | ( | void * | user_data, | |
| const char * | file, | |||
| const char * | func, | |||
| int | line, | |||
| const char * | var | |||
| ) |
Definition at line 233 of file astobj2.c.
References ast_atomic_fetchadd_int(), ast_mutex_trylock(), INTERNAL_OBJ(), __priv_data::lock, and astobj2::priv_data.
00234 { 00235 struct astobj2 *p = INTERNAL_OBJ(user_data); 00236 int ret; 00237 00238 if (p == NULL) 00239 return -1; 00240 #ifndef DEBUG_THREADS 00241 ret = ast_mutex_trylock(&p->priv_data.lock); 00242 #else 00243 ret = __ast_pthread_mutex_trylock(file, line, func, var, &p->priv_data.lock); 00244 #endif 00245 00246 #ifdef AO2_DEBUG 00247 if (!ret) 00248 ast_atomic_fetchadd_int(&ao2.total_locked, 1); 00249 #endif 00250 return ret; 00251 }
| void* _ao2_unlink | ( | struct ao2_container * | c, | |
| void * | user_data | |||
| ) |
Definition at line 611 of file astobj2.c.
References _ao2_callback(), ao2_match_by_addr, INTERNAL_OBJ(), OBJ_NODATA, OBJ_POINTER, and OBJ_UNLINK.
00612 { 00613 if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */ 00614 return NULL; 00615 00616 _ao2_callback(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data); 00617 00618 return NULL; 00619 }
| void* _ao2_unlink_debug | ( | struct ao2_container * | c, | |
| void * | user_data, | |||
| char * | tag, | |||
| char * | file, | |||
| int | line, | |||
| const char * | funcname | |||
| ) |
Definition at line 600 of file astobj2.c.
References _ao2_callback_debug(), ao2_match_by_addr, INTERNAL_OBJ(), OBJ_NODATA, OBJ_POINTER, and OBJ_UNLINK.
00602 { 00603 if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */ 00604 return NULL; 00605 00606 _ao2_callback_debug(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data, tag, file, line, funcname); 00607 00608 return NULL; 00609 }
| int _ao2_unlock | ( | void * | user_data, | |
| const char * | file, | |||
| const char * | func, | |||
| int | line, | |||
| const char * | var | |||
| ) |
Definition at line 199 of file astobj2.c.
References ast_atomic_fetchadd_int(), ast_mutex_unlock(), INTERNAL_OBJ(), __priv_data::lock, and astobj2::priv_data.
00200 { 00201 struct astobj2 *p = INTERNAL_OBJ(user_data); 00202 00203 if (p == NULL) 00204 return -1; 00205 00206 #ifdef AO2_DEBUG 00207 ast_atomic_fetchadd_int(&ao2.total_locked, -1); 00208 #endif 00209 00210 #ifndef DEBUG_THREADS 00211 return ast_mutex_unlock(&p->priv_data.lock); 00212 #else 00213 return __ast_pthread_mutex_unlock(file, line, func, var, &p->priv_data.lock); 00214 #endif 00215 }
| void ao2_bt | ( | void | ) |
Definition at line 83 of file astobj2.c.
References ast_verbose, free, and N1.
00084 { 00085 int c, i; 00086 #define N1 20 00087 void *addresses[N1]; 00088 char **strings; 00089 00090 c = backtrace(addresses, N1); 00091 strings = backtrace_symbols(addresses,c); 00092 ast_verbose("backtrace returned: %d\n", c); 00093 for(i = 0; i < c; i++) { 00094 ast_verbose("%d: %p %s\n", i, addresses[i], strings[i]); 00095 } 00096 free(strings); 00097 }
| int ao2_container_count | ( | struct ao2_container * | c | ) |
Returns the number of elements in a container.
return the number of elements in the container
Definition at line 516 of file astobj2.c.
References ao2_container::elements.
Referenced by __queues_show(), _sip_show_peers(), ast_tone_zone_count(), cli_tps_report(), do_timing(), get_unused_callno(), lock_broker(), pthread_timer_open(), and unload_module().
00517 { 00518 return c->elements; 00519 }
| void ao2_iterator_destroy | ( | struct ao2_iterator * | i | ) |
Destroy a container iterator.
destroy an iterator
Definition at line 837 of file astobj2.c.
References ao2_ref, and ao2_iterator::c.
Referenced by __iax2_show_peers(), __queues_show(), _sip_show_peers(), action_meetmelist(), alias_show(), authenticate_reply(), check_access(), clear_queue(), clear_stats(), cli_console_active(), cli_list_devices(), compare_weight(), complete_iax2_peers(), complete_iax2_unregister(), complete_meetmecmd(), complete_queue(), complete_queue_remove_member(), complete_sip_peer(), complete_sip_registered_peer(), complete_sip_user(), complete_sipch(), conf_queue_dtmf(), delete_profiles(), delete_routes(), delete_users(), destroy_pvts(), dialgroup_read(), dump_queue_members(), find_queue_by_name_rt(), free_members(), get_member_status(), handle_cli_iax2_show_callno_limits(), handle_cli_iax2_show_users(), handle_cli_moh_show_classes(), handle_cli_moh_show_files(), handle_cli_odbc_show(), handle_feature_show(), handle_request_subscribe(), handle_show_routes(), handle_statechange(), iax2_getpeername(), iax2_getpeertrunk(), interface_exists(), manager_iax2_show_peer_list(), manager_queues_status(), manager_queues_summary(), meetme_show_cmd(), num_available_members(), poke_all_peers(), pp_each_user_exec(), prune_peers(), prune_users(), queue_function_qac(), queue_function_qac_dep(), queue_function_queuememberlist(), reload(), rt_handle_member_record(), set_member_paused(), set_member_penalty(), sip_poke_all_peers(), sip_prune_realtime(), sip_show_channel(), sip_show_history(), sip_show_inuse(), sip_show_tcp(), sip_show_users(), stop_streams(), try_calling(), unload_module(), update_queue(), and update_realtime_members().
| struct ao2_iterator ao2_iterator_init | ( | struct ao2_container * | c, | |
| int | flags | |||
| ) | [read] |
Create an iterator for a container.
initialize an iterator so we start from the first object
Definition at line 822 of file astobj2.c.
References ao2_ref, ao2_iterator::c, and ao2_iterator::flags.
Referenced by __iax2_show_peers(), __queues_show(), _sip_show_peers(), action_meetmelist(), alias_show(), ast_tone_zone_iterator_init(), authenticate_reply(), check_access(), clear_queue(), clear_stats(), cli_console_active(), cli_list_devices(), cli_tps_report(), compare_weight(), complete_country(), complete_iax2_peers(), complete_iax2_unregister(), complete_meetmecmd(), complete_queue(), complete_queue_remove_member(), complete_sip_peer(), complete_sip_registered_peer(), complete_sip_user(), complete_sipch(), conf_queue_dtmf(), delete_profiles(), delete_routes(), delete_users(), destroy_pvts(), dialgroup_read(), do_parking_thread(), dump_queue_members(), find_queue_by_name_rt(), free_members(), get_member_status(), handle_cli_iax2_show_callno_limits(), handle_cli_iax2_show_users(), handle_cli_moh_show_classes(), handle_cli_moh_show_files(), handle_cli_odbc_show(), handle_feature_show(), handle_parkedcalls(), handle_request_subscribe(), handle_show_routes(), handle_statechange(), iax2_getpeername(), iax2_getpeertrunk(), interface_exists(), manager_iax2_show_peer_list(), manager_parking_status(), manager_queues_status(), manager_queues_summary(), meetme_show_cmd(), num_available_members(), poke_all_peers(), pp_each_user_exec(), prune_peers(), prune_users(), queue_function_qac(), queue_function_qac_dep(), queue_function_queuememberlist(), reload(), rt_handle_member_record(), set_member_paused(), set_member_penalty(), sip_poke_all_peers(), sip_prune_realtime(), sip_show_channel(), sip_show_history(), sip_show_inuse(), sip_show_tcp(), sip_show_users(), stop_streams(), tps_taskprocessor_tab_complete(), try_calling(), unload_module(), update_queue(), and update_realtime_members().
00823 { 00824 struct ao2_iterator a = { 00825 .c = c, 00826 .flags = flags 00827 }; 00828 00829 ao2_ref(c, +1); 00830 00831 return a; 00832 }
| int ao2_lock | ( | void * | a | ) |
Lock an object.
| a | A pointer to the object we want to lock. |
Definition at line 153 of file astobj2.c.
References ast_atomic_fetchadd_int(), ast_mutex_lock(), INTERNAL_OBJ(), __priv_data::lock, and astobj2::priv_data.
Referenced by __ao2_callback(), __ao2_iterator_next(), __ao2_link(), __queues_show(), _sip_show_peers(), _sip_tcp_helper_thread(), add_calltoken_ignore(), add_to_queue(), ast_bridge_depart(), ast_bridge_destroy(), ast_bridge_dtmf_stream(), ast_bridge_merge(), ast_bridge_remove(), ast_bridge_suspend(), ast_bridge_unsuspend(), ast_get_indication_tone(), ast_get_indication_zone(), ast_register_indication_country(), ast_set_indication_country(), ast_taskprocessor_get(), ast_taskprocessor_unreference(), ast_unregister_indication_country(), attended_abort_transfer(), bridge_channel_join(), bridge_channel_join_multithreaded(), bridge_channel_join_singlethreaded(), bridge_thread(), build_callno_limits(), build_parkinglot(), clear_stats(), compare_weight(), complete_queue_remove_member(), complete_sip_user(), conf_run(), end_bridge_callback(), find_call(), find_queue_by_name_rt(), generic_thread_loop(), get_member_penalty(), get_member_status(), get_unused_callno(), handle_request_subscribe(), handle_statechange(), inprocess_count(), is_our_turn(), join_conference_bridge(), join_queue(), leave_conference_bridge(), leave_queue(), load_config(), load_indications(), load_realtime_queue(), manager_queues_status(), manager_queues_summary(), menu_callback(), moh_release(), mohalloc(), monmp3thread(), multiplexed_add_or_remove(), multiplexed_bridge_create(), multiplexed_bridge_destroy(), multiplexed_thread_function(), mwi_event_cb(), peercnt_add(), peercnt_remove(), play_prompt_to_channel(), post_join_marked(), post_join_unmarked(), pthread_timer_ack(), pthread_timer_disable_continuous(), pthread_timer_enable_continuous(), pthread_timer_get_event(), pthread_timer_open(), pthread_timer_set_rate(), queue_function_qac(), queue_function_qac_dep(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_function_var(), recalc_holdtime(), record_abandoned(), reload_queue_members(), reload_queues(), reload_single_queue(), remove_from_queue(), replace_callno(), ring_entry(), run_timer(), set_member_paused(), set_member_penalty(), sip_poke_all_peers(), sip_prune_realtime(), sip_show_inuse(), sip_show_user(), sip_show_users(), sip_tcptls_write(), smart_bridge_operation(), softmix_bridge_thread(), try_calling(), update_call_counter(), update_queue(), and update_realtime_members().
00154 { 00155 struct astobj2 *p = INTERNAL_OBJ(user_data); 00156 00157 if (p == NULL) 00158 return -1; 00159 00160 #ifdef AO2_DEBUG 00161 ast_atomic_fetchadd_int(&ao2.total_locked, 1); 00162 #endif 00163 00164 return ast_mutex_lock(&p->priv_data.lock); 00165 }
| int ao2_match_by_addr | ( | void * | user_data, | |
| void * | arg, | |||
| int | flags | |||
| ) |
| void* ao2_object_get_lockaddr | ( | void * | obj | ) |
Return the lock address of an object.
| [in] | obj | A pointer to the object we want. |
Definition at line 253 of file astobj2.c.
References INTERNAL_OBJ(), __priv_data::lock, and astobj2::priv_data.
00254 { 00255 struct astobj2 *p = INTERNAL_OBJ(obj); 00256 00257 if (p == NULL) 00258 return NULL; 00259 00260 return &p->priv_data.lock; 00261 }
| int ao2_trylock | ( | void * | a | ) |
Try locking-- (don't block if fail).
| a | A pointer to the object we want to lock. |
Definition at line 217 of file astobj2.c.
References ast_atomic_fetchadd_int(), ast_mutex_trylock(), INTERNAL_OBJ(), __priv_data::lock, and astobj2::priv_data.
00218 { 00219 struct astobj2 *p = INTERNAL_OBJ(user_data); 00220 int ret; 00221 00222 if (p == NULL) 00223 return -1; 00224 ret = ast_mutex_trylock(&p->priv_data.lock); 00225 00226 #ifdef AO2_DEBUG 00227 if (!ret) 00228 ast_atomic_fetchadd_int(&ao2.total_locked, 1); 00229 #endif 00230 return ret; 00231 }
| int ao2_unlock | ( | void * | a | ) |
Unlock an object.
| a | A pointer to the object we want unlock. |
Definition at line 185 of file astobj2.c.
References ast_atomic_fetchadd_int(), ast_mutex_unlock(), INTERNAL_OBJ(), __priv_data::lock, and astobj2::priv_data.
Referenced by __ao2_callback(), __queues_show(), _ao2_iterator_next(), _ao2_iterator_next_debug(), _ao2_link(), _ao2_link_debug(), _sip_show_peers(), _sip_tcp_helper_thread(), add_calltoken_ignore(), add_to_queue(), ast_bridge_depart(), ast_bridge_destroy(), ast_bridge_dtmf_stream(), ast_bridge_merge(), ast_bridge_remove(), ast_bridge_suspend(), ast_bridge_unsuspend(), ast_get_indication_tone(), ast_get_indication_zone(), ast_register_indication_country(), ast_set_indication_country(), ast_taskprocessor_get(), ast_taskprocessor_unreference(), ast_unregister_indication_country(), attended_abort_transfer(), bridge_channel_join(), bridge_channel_join_multithreaded(), bridge_channel_join_singlethreaded(), bridge_thread(), build_callno_limits(), build_parkinglot(), clear_stats(), compare_weight(), complete_queue_remove_member(), complete_sip_user(), conf_run(), end_bridge_callback(), find_call(), find_queue_by_name_rt(), generic_thread_loop(), get_member_penalty(), get_member_status(), get_unused_callno(), handle_request_subscribe(), handle_statechange(), inprocess_count(), is_our_turn(), join_conference_bridge(), join_queue(), leave_conference_bridge(), leave_queue(), load_config(), load_indications(), load_realtime_queue(), manager_queues_status(), manager_queues_summary(), menu_callback(), moh_release(), mohalloc(), monmp3thread(), multiplexed_add_or_remove(), multiplexed_bridge_create(), multiplexed_bridge_destroy(), multiplexed_thread_function(), mwi_event_cb(), peercnt_add(), peercnt_remove(), play_prompt_to_channel(), post_join_marked(), post_join_unmarked(), pthread_timer_ack(), pthread_timer_disable_continuous(), pthread_timer_enable_continuous(), pthread_timer_get_event(), pthread_timer_open(), pthread_timer_set_rate(), queue_function_qac(), queue_function_qac_dep(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_function_var(), recalc_holdtime(), record_abandoned(), reload_queue_members(), reload_queues(), reload_single_queue(), remove_from_queue(), replace_callno(), ring_entry(), run_timer(), set_member_paused(), set_member_penalty(), sip_poke_all_peers(), sip_prune_realtime(), sip_show_inuse(), sip_show_user(), sip_show_users(), sip_tcptls_write(), smart_bridge_operation(), softmix_bridge_thread(), try_calling(), update_call_counter(), update_queue(), and update_realtime_members().
00186 { 00187 struct astobj2 *p = INTERNAL_OBJ(user_data); 00188 00189 if (p == NULL) 00190 return -1; 00191 00192 #ifdef AO2_DEBUG 00193 ast_atomic_fetchadd_int(&ao2.total_locked, -1); 00194 #endif 00195 00196 return ast_mutex_unlock(&p->priv_data.lock); 00197 }
| int astobj2_init | ( | void | ) |
Provided by astobj2.c
Definition at line 1123 of file astobj2.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
01124 { 01125 #ifdef AO2_DEBUG 01126 ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); 01127 #endif 01128 01129 return 0; 01130 }
| static int cb_true | ( | void * | user_data, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
special callback that matches all
Definition at line 624 of file astobj2.c.
References CMP_MATCH.
Referenced by __ao2_callback().
00625 { 00626 return CMP_MATCH; 00627 }
| static int cb_true_data | ( | void * | user_data, | |
| void * | arg, | |||
| void * | data, | |||
| int | flags | |||
| ) | [static] |
similar to cb_true, but is an ao2_callback_data_fn instead
Definition at line 632 of file astobj2.c.
References CMP_MATCH.
Referenced by __ao2_callback().
00633 { 00634 return CMP_MATCH; 00635 }
| static int cd_cb | ( | void * | obj, | |
| void * | arg, | |||
| int | flag | |||
| ) | [static] |
Definition at line 940 of file astobj2.c.
References _ao2_ref().
Referenced by container_destruct().
00941 { 00942 _ao2_ref(obj, -1); 00943 return 0; 00944 }
| static int cd_cb_debug | ( | void * | obj, | |
| void * | arg, | |||
| int | flag | |||
| ) | [static] |
Definition at line 946 of file astobj2.c.
References _ao2_ref_debug().
Referenced by container_destruct_debug().
00947 { 00948 _ao2_ref_debug(obj, -1, "deref object via container destroy", __FILE__, __LINE__, __PRETTY_FUNCTION__); 00949 return 0; 00950 }
| static void container_destruct | ( | void * | c | ) | [static] |
Definition at line 952 of file astobj2.c.
References _ao2_callback(), ast_atomic_fetchadd_int(), ast_free, AST_LIST_REMOVE_HEAD, ao2_container::buckets, cd_cb(), bucket_list::entry, ao2_container::n_buckets, and OBJ_UNLINK.
Referenced by _ao2_container_alloc().
00953 { 00954 struct ao2_container *c = _c; 00955 int i; 00956 00957 _ao2_callback(c, OBJ_UNLINK, cd_cb, NULL); 00958 00959 for (i = 0; i < c->n_buckets; i++) { 00960 struct bucket_list *current; 00961 00962 while ((current = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) { 00963 ast_free(current); 00964 } 00965 } 00966 00967 #ifdef AO2_DEBUG 00968 ast_atomic_fetchadd_int(&ao2.total_containers, -1); 00969 #endif 00970 }
| static void container_destruct_debug | ( | void * | c | ) | [static] |
Definition at line 972 of file astobj2.c.
References _ao2_callback_debug(), ast_atomic_fetchadd_int(), ast_free, AST_LIST_REMOVE_HEAD, ao2_container::buckets, cd_cb_debug(), bucket_list::entry, ao2_container::n_buckets, and OBJ_UNLINK.
Referenced by _ao2_container_alloc_debug().
00973 { 00974 struct ao2_container *c = _c; 00975 int i; 00976 00977 _ao2_callback_debug(c, OBJ_UNLINK, cd_cb_debug, NULL, "container_destruct_debug called", __FILE__, __LINE__, __PRETTY_FUNCTION__); 00978 00979 for (i = 0; i < c->n_buckets; i++) { 00980 struct bucket_list *current; 00981 00982 while ((current = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) { 00983 ast_free(current); 00984 } 00985 } 00986 00987 #ifdef AO2_DEBUG 00988 ast_atomic_fetchadd_int(&ao2.total_containers, -1); 00989 #endif 00990 }
| static int hash_zero | ( | const void * | user_obj, | |
| const int | flags | |||
| ) | [static] |
always zero hash function
it is convenient to have a hash function that always returns 0. This is basically used when we want to have a container that is a simple linked list.
Definition at line 459 of file astobj2.c.
Referenced by __ao2_container_alloc().
| static struct astobj2* INTERNAL_OBJ | ( | void * | user_data | ) | [static, read] |
convert from a pointer _p to a user-defined object
Definition at line 105 of file astobj2.c.
References AO2_MAGIC, ast_log(), LOG_ERROR, __priv_data::magic, and astobj2::priv_data.
Referenced by __ao2_callback(), __ao2_iterator_next(), __ao2_link(), __ao2_ref(), _ao2_lock(), _ao2_ref(), _ao2_ref_debug(), _ao2_trylock(), _ao2_unlink(), _ao2_unlink_debug(), _ao2_unlock(), ao2_lock(), ao2_object_get_lockaddr(), ao2_trylock(), and ao2_unlock().
00106 { 00107 struct astobj2 *p; 00108 00109 if (!user_data) { 00110 ast_log(LOG_ERROR, "user_data is NULL\n"); 00111 return NULL; 00112 } 00113 00114 p = (struct astobj2 *) ((char *) user_data - sizeof(*p)); 00115 if (AO2_MAGIC != (p->priv_data.magic) ) { 00116 ast_log(LOG_ERROR, "bad magic number 0x%x for %p\n", p->priv_data.magic, p); 00117 p = NULL; 00118 } 00119 00120 return p; 00121 }
1.5.9