Add ability to pass arbitrary data to the ao2_callback_fn (called from

ao2_callback and ao2_find).  Currently, passing OBJ_POINTER to either
of these mandates that the passed 'arg' is a hashable object, making
searching for an ao2 object based on outside criteria difficult.

Reviewed by Russell and Mark M. via ReviewBoard:
    http://reviewboard.digium.com/r/36/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@155401 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Sean Bright 17 years ago
parent bd3f685f20
commit 30d1744ffc

@ -853,7 +853,7 @@ static int queue_hash_cb(const void *obj, const int flags)
return ast_str_hash(q->name); return ast_str_hash(q->name);
} }
static int queue_cmp_cb(void *obj, void *arg, int flags) static int queue_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct call_queue *q = obj, *q2 = arg; struct call_queue *q = obj, *q2 = arg;
return !strcasecmp(q->name, q2->name) ? CMP_MATCH | CMP_STOP : 0; return !strcasecmp(q->name, q2->name) ? CMP_MATCH | CMP_STOP : 0;
@ -1126,7 +1126,7 @@ static int member_hash_fn(const void *obj, const int flags)
return ret; return ret;
} }
static int member_cmp_fn(void *obj1, void *obj2, int flags) static int member_cmp_fn(void *obj1, void *obj2, void *data, int flags)
{ {
struct member *mem1 = obj1, *mem2 = obj2; struct member *mem1 = obj1, *mem2 = obj2;
return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP; return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP;
@ -1640,7 +1640,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
char tmpbuf[64]; /* Must be longer than the longest queue param name. */ char tmpbuf[64]; /* Must be longer than the longest queue param name. */
/* Static queues override realtime. */ /* Static queues override realtime. */
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
ao2_lock(q); ao2_lock(q);
if (!q->realtime) { if (!q->realtime) {
if (q->dead) { if (q->dead) {
@ -1767,7 +1767,7 @@ static struct call_queue *load_realtime_queue(const char *queuename)
}; };
/* Find the queue in the in-core list first. */ /* Find the queue in the in-core list first. */
q = ao2_find(queues, &tmpq, OBJ_POINTER); q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER);
if (!q || q->realtime) { if (!q || q->realtime) {
/*! \note Load from realtime before taking the "queues" container lock, to avoid blocking all /*! \note Load from realtime before taking the "queues" container lock, to avoid blocking all
@ -2238,7 +2238,7 @@ static int compare_weight(struct call_queue *rq, struct member *member)
} }
ao2_lock(q); ao2_lock(q);
if (q->count && q->members) { if (q->count && q->members) {
if ((mem = ao2_find(q->members, member, OBJ_POINTER))) { if ((mem = ao2_find(q->members, member, NULL, OBJ_POINTER))) {
ast_debug(1, "Found matching member %s in queue '%s'\n", mem->interface, q->name); ast_debug(1, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
if (q->weight > rq->weight) { if (q->weight > rq->weight) {
ast_debug(1, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count); ast_debug(1, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
@ -3128,7 +3128,7 @@ static int update_queue(struct call_queue *q, struct member *member, int callcom
queue_iter = ao2_iterator_init(queues, 0); queue_iter = ao2_iterator_init(queues, 0);
while ((qtmp = ao2_iterator_next(&queue_iter))) { while ((qtmp = ao2_iterator_next(&queue_iter))) {
ao2_lock(qtmp); ao2_lock(qtmp);
if ((mem = ao2_find(qtmp->members, member, OBJ_POINTER))) { if ((mem = ao2_find(qtmp->members, member, NULL, OBJ_POINTER))) {
time(&mem->lastcall); time(&mem->lastcall);
mem->calls++; mem->calls++;
mem->lastqueue = q; mem->lastqueue = q;
@ -4175,10 +4175,10 @@ static int remove_from_queue(const char *queuename, const char *interface)
int res = RES_NOSUCHQUEUE; int res = RES_NOSUCHQUEUE;
ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface)); ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface));
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
ao2_lock(queues); ao2_lock(queues);
ao2_lock(q); ao2_lock(q);
if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER))) { if ((mem = ao2_find(q->members, &tmpmem, NULL, OBJ_POINTER))) {
/* XXX future changes should beware of this assumption!! */ /* XXX future changes should beware of this assumption!! */
if (!mem->dynamic) { if (!mem->dynamic) {
ao2_ref(mem, -1); ao2_ref(mem, -1);
@ -4401,7 +4401,7 @@ static int get_member_penalty(char *queuename, char *interface)
}; };
struct member *mem; struct member *mem;
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
foundqueue = 1; foundqueue = 1;
ao2_lock(q); ao2_lock(q);
if ((mem = interface_exists(q, interface))) { if ((mem = interface_exists(q, interface))) {
@ -4453,7 +4453,7 @@ static void reload_queue_members(void)
struct call_queue tmpq = { struct call_queue tmpq = {
.name = queue_name, .name = queue_name,
}; };
cur_queue = ao2_find(queues, &tmpq, OBJ_POINTER); cur_queue = ao2_find(queues, &tmpq, NULL, OBJ_POINTER);
} }
if (!cur_queue) if (!cur_queue)
@ -5077,7 +5077,7 @@ static int queue_function_var(struct ast_channel *chan, const char *cmd, char *d
return -1; return -1;
} }
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
ao2_lock(q); ao2_lock(q);
if (q->setqueuevar) { if (q->setqueuevar) {
sl = 0; sl = 0;
@ -5218,7 +5218,7 @@ static int queue_function_queuewaitingcount(struct ast_channel *chan, const char
return -1; return -1;
} }
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
ao2_lock(q); ao2_lock(q);
count = q->count; count = q->count;
ao2_unlock(q); ao2_unlock(q);
@ -5254,7 +5254,7 @@ static int queue_function_queuememberlist(struct ast_channel *chan, const char *
return -1; return -1;
} }
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
int buflen = 0, count = 0; int buflen = 0, count = 0;
struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0); struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0);
@ -5511,7 +5511,7 @@ static int reload_queues(int reload)
struct call_queue tmpq = { struct call_queue tmpq = {
.name = cat, .name = cat,
}; };
if (!(q = ao2_find(queues, &tmpq, OBJ_POINTER))) { if (!(q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
/* Make one then */ /* Make one then */
if (!(q = alloc_queue(cat))) { if (!(q = alloc_queue(cat))) {
/* TODO: Handle memory allocation failure */ /* TODO: Handle memory allocation failure */
@ -5589,7 +5589,7 @@ static int reload_queues(int reload)
/* Find the old position in the list */ /* Find the old position in the list */
ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface)); ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface));
cur = ao2_find(q->members, &tmpmem, OBJ_POINTER | OBJ_UNLINK); cur = ao2_find(q->members, &tmpmem, NULL, OBJ_POINTER | OBJ_UNLINK);
newm = create_queue_member(interface, membername, penalty, cur ? cur->paused : 0, state_interface); newm = create_queue_member(interface, membername, penalty, cur ? cur->paused : 0, state_interface);
ao2_link(q->members, newm); ao2_link(q->members, newm);
ao2_ref(newm, -1); ao2_ref(newm, -1);

@ -251,7 +251,7 @@ static struct console_pvt *find_pvt(const char *name)
.name = name, .name = name,
}; };
return ao2_find(pvts, &tmp_pvt, OBJ_POINTER); return ao2_find(pvts, &tmp_pvt, NULL, OBJ_POINTER);
} }
/*! /*!
@ -1351,7 +1351,7 @@ static void build_device(struct ast_config *cfg, const char *name)
unref_pvt(pvt); unref_pvt(pvt);
} }
static int pvt_mark_destroy_cb(void *obj, void *arg, int flags) static int pvt_mark_destroy_cb(void *obj, void *arg, void *data, int flags)
{ {
struct console_pvt *pvt = obj; struct console_pvt *pvt = obj;
pvt->destroy = 1; pvt->destroy = 1;
@ -1403,7 +1403,7 @@ static int load_config(int reload)
return -1; return -1;
} }
ao2_callback(pvts, OBJ_NODATA, pvt_mark_destroy_cb, NULL); ao2_callback(pvts, OBJ_NODATA, pvt_mark_destroy_cb, NULL, NULL);
ast_mutex_lock(&globals_lock); ast_mutex_lock(&globals_lock);
for (v = ast_variable_browse(cfg, "general"); v; v = v->next) for (v = ast_variable_browse(cfg, "general"); v; v = v->next)
@ -1429,7 +1429,7 @@ static int pvt_hash_cb(const void *obj, const int flags)
return ast_str_hash(pvt->name); return ast_str_hash(pvt->name);
} }
static int pvt_cmp_cb(void *obj, void *arg, int flags) static int pvt_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct console_pvt *pvt = obj, *pvt2 = arg; struct console_pvt *pvt = obj, *pvt2 = arg;

@ -1399,7 +1399,7 @@ static int peer_hash_cb(const void *obj, const int flags)
/*! /*!
* \note The only member of the peer passed here guaranteed to be set is the name field * \note The only member of the peer passed here guaranteed to be set is the name field
*/ */
static int peer_cmp_cb(void *obj, void *arg, int flags) static int peer_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct iax2_peer *peer = obj, *peer2 = arg; struct iax2_peer *peer = obj, *peer2 = arg;
@ -1419,7 +1419,7 @@ static int user_hash_cb(const void *obj, const int flags)
/*! /*!
* \note The only member of the user passed here guaranteed to be set is the name field * \note The only member of the user passed here guaranteed to be set is the name field
*/ */
static int user_cmp_cb(void *obj, void *arg, int flags) static int user_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct iax2_user *user = obj, *user2 = arg; struct iax2_user *user = obj, *user2 = arg;
@ -1437,7 +1437,7 @@ static struct iax2_peer *find_peer(const char *name, int realtime)
.name = name, .name = name,
}; };
peer = ao2_find(peers, &tmp_peer, OBJ_POINTER); peer = ao2_find(peers, &tmp_peer, NULL, OBJ_POINTER);
/* Now go for realtime if applicable */ /* Now go for realtime if applicable */
if(!peer && realtime) if(!peer && realtime)
@ -1511,7 +1511,7 @@ static void iax2_destroy_helper(struct chan_iax2_pvt *pvt)
.name = pvt->username, .name = pvt->username,
}; };
user = ao2_find(users, &tmp_user, OBJ_POINTER); user = ao2_find(users, &tmp_user, NULL, OBJ_POINTER);
if (user) { if (user) {
ast_atomic_fetchadd_int(&user->curauthreq, -1); ast_atomic_fetchadd_int(&user->curauthreq, -1);
user_unref(user); user_unref(user);
@ -1778,7 +1778,7 @@ static int __find_callno(unsigned short callno, unsigned short dcallno, struct s
memcpy(&tmp_pvt.addr, sin, sizeof(tmp_pvt.addr)); memcpy(&tmp_pvt.addr, sin, sizeof(tmp_pvt.addr));
if ((pvt = ao2_find(iax_peercallno_pvts, &tmp_pvt, OBJ_POINTER))) { if ((pvt = ao2_find(iax_peercallno_pvts, &tmp_pvt, NULL, OBJ_POINTER))) {
if (return_locked) { if (return_locked) {
ast_mutex_lock(&iaxsl[pvt->callno]); ast_mutex_lock(&iaxsl[pvt->callno]);
} }
@ -5407,7 +5407,7 @@ static char *handle_cli_iax2_unregister(struct ast_cli_entry *e, int cmd, struct
}; };
struct iax2_peer *peer; struct iax2_peer *peer;
peer = ao2_find(peers, &tmp_peer, OBJ_POINTER); peer = ao2_find(peers, &tmp_peer, NULL, OBJ_POINTER);
if (peer) { if (peer) {
expire_registry(peer_ref(peer)); /* will release its own reference when done */ expire_registry(peer_ref(peer)); /* will release its own reference when done */
peer_unref(peer); /* ref from ao2_find() */ peer_unref(peer); /* ref from ao2_find() */
@ -6299,7 +6299,7 @@ static int authenticate_request(int call_num)
.name = p->username, .name = p->username,
}; };
user = ao2_find(users, &tmp_user, OBJ_POINTER); user = ao2_find(users, &tmp_user, NULL, OBJ_POINTER);
if (user) { if (user) {
if (user->curauthreq == user->maxauthreq) if (user->curauthreq == user->maxauthreq)
authreq_restrict = 1; authreq_restrict = 1;
@ -6349,7 +6349,7 @@ static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies)
.name = p->username, .name = p->username,
}; };
user = ao2_find(users, &tmp_user, OBJ_POINTER); user = ao2_find(users, &tmp_user, NULL, OBJ_POINTER);
if (user) { if (user) {
if (ast_test_flag(p, IAX_MAXAUTHREQ)) { if (ast_test_flag(p, IAX_MAXAUTHREQ)) {
ast_atomic_fetchadd_int(&user->curauthreq, -1); ast_atomic_fetchadd_int(&user->curauthreq, -1);
@ -10226,7 +10226,7 @@ static int iax2_poke_noanswer(const void *data)
return 0; return 0;
} }
static int iax2_poke_peer_cb(void *obj, void *arg, int flags) static int iax2_poke_peer_cb(void *obj, void *arg, void *data, int flags)
{ {
struct iax2_peer *peer = obj; struct iax2_peer *peer = obj;
@ -10666,7 +10666,7 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st
}; };
if (!temponly) { if (!temponly) {
peer = ao2_find(peers, &tmp_peer, OBJ_POINTER); peer = ao2_find(peers, &tmp_peer, NULL, OBJ_POINTER);
if (peer && !ast_test_flag(peer, IAX_DELME)) if (peer && !ast_test_flag(peer, IAX_DELME))
firstpass = 0; firstpass = 0;
} }
@ -10920,7 +10920,7 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v, st
}; };
if (!temponly) { if (!temponly) {
user = ao2_find(users, &tmp_user, OBJ_POINTER); user = ao2_find(users, &tmp_user, NULL, OBJ_POINTER);
if (user && !ast_test_flag(user, IAX_DELME)) if (user && !ast_test_flag(user, IAX_DELME))
firstpass = 0; firstpass = 0;
} }
@ -11120,7 +11120,7 @@ cleanup:
return user; return user;
} }
static int peer_delme_cb(void *obj, void *arg, int flags) static int peer_delme_cb(void *obj, void *arg, void *data, int flags)
{ {
struct iax2_peer *peer = obj; struct iax2_peer *peer = obj;
@ -11129,7 +11129,7 @@ static int peer_delme_cb(void *obj, void *arg, int flags)
return 0; return 0;
} }
static int user_delme_cb(void *obj, void *arg, int flags) static int user_delme_cb(void *obj, void *arg, void *data, int flags)
{ {
struct iax2_user *user = obj; struct iax2_user *user = obj;
@ -11142,7 +11142,7 @@ static void delete_users(void)
{ {
struct iax2_registry *reg; struct iax2_registry *reg;
ao2_callback(users, 0, user_delme_cb, NULL); ao2_callback(users, 0, user_delme_cb, NULL, NULL);
AST_LIST_LOCK(&registrations); AST_LIST_LOCK(&registrations);
while ((reg = AST_LIST_REMOVE_HEAD(&registrations, entry))) { while ((reg = AST_LIST_REMOVE_HEAD(&registrations, entry))) {
@ -11162,7 +11162,7 @@ static void delete_users(void)
} }
AST_LIST_UNLOCK(&registrations); AST_LIST_UNLOCK(&registrations);
ao2_callback(peers, 0, peer_delme_cb, NULL); ao2_callback(peers, 0, peer_delme_cb, NULL, NULL);
} }
static void prune_users(void) static void prune_users(void)
@ -12410,7 +12410,7 @@ static int unload_module(void)
return __unload_module(); return __unload_module();
} }
static int peer_set_sock_cb(void *obj, void *arg, int flags) static int peer_set_sock_cb(void *obj, void *arg, void *data, int flags)
{ {
struct iax2_peer *peer = obj; struct iax2_peer *peer = obj;
@ -12427,7 +12427,7 @@ static int pvt_hash_cb(const void *obj, const int flags)
return pvt->peercallno; return pvt->peercallno;
} }
static int pvt_cmp_cb(void *obj, void *arg, int flags) static int pvt_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct chan_iax2_pvt *pvt = obj, *pvt2 = arg; struct chan_iax2_pvt *pvt = obj, *pvt2 = arg;
@ -12541,8 +12541,8 @@ static int load_module(void)
iax2_do_register(reg); iax2_do_register(reg);
AST_LIST_UNLOCK(&registrations); AST_LIST_UNLOCK(&registrations);
ao2_callback(peers, 0, peer_set_sock_cb, NULL); ao2_callback(peers, 0, peer_set_sock_cb, NULL, NULL);
ao2_callback(peers, 0, iax2_poke_peer_cb, NULL); ao2_callback(peers, 0, iax2_poke_peer_cb, NULL, NULL);
reload_firmware(0); reload_firmware(0);

@ -1963,7 +1963,7 @@ static int peer_hash_cb(const void *obj, const int flags)
/*! /*!
* \note The only member of the peer used here is the name field * \note The only member of the peer used here is the name field
*/ */
static int peer_cmp_cb(void *obj, void *arg, int flags) static int peer_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct sip_peer *peer = obj, *peer2 = arg; struct sip_peer *peer = obj, *peer2 = arg;
@ -1990,7 +1990,7 @@ static int peer_iphash_cb(const void *obj, const int flags)
/*! /*!
* \note the peer's addr struct provides to fields combined to make a key: the sin_addr.s_addr and sin_port fields. * \note the peer's addr struct provides to fields combined to make a key: the sin_addr.s_addr and sin_port fields.
*/ */
static int peer_ipcmp_cb(void *obj, void *arg, int flags) static int peer_ipcmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct sip_peer *peer = obj, *peer2 = arg; struct sip_peer *peer = obj, *peer2 = arg;
@ -2019,7 +2019,7 @@ static int dialog_hash_cb(const void *obj, const int flags)
/*! /*!
* \note The only member of the dialog used here callid string * \note The only member of the dialog used here callid string
*/ */
static int dialog_cmp_cb(void *obj, void *arg, int flags) static int dialog_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct sip_pvt *pvt = obj, *pvt2 = arg; struct sip_pvt *pvt = obj, *pvt2 = arg;
@ -4435,9 +4435,9 @@ static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int
struct sip_peer tmp_peer; struct sip_peer tmp_peer;
/* Inline function to assist finding peers by name only */ /* Inline function to assist finding peers by name only */
auto int find_by_name(void *obj, void *arg, int flags); auto int find_by_name(void *obj, void *arg, void *data, int flags);
int find_by_name(void *obj, void *arg, int flags) int find_by_name(void *obj, void *arg, void *data, int flags)
{ {
struct sip_peer *search = obj, *match = arg; struct sip_peer *search = obj, *match = arg;
@ -4457,15 +4457,15 @@ static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int
if (peer) { if (peer) {
ast_copy_string(tmp_peer.name, peer, sizeof(tmp_peer.name)); ast_copy_string(tmp_peer.name, peer, sizeof(tmp_peer.name));
p = ao2_t_callback(peers, OBJ_POINTER, find_by_name, &tmp_peer, "ao2_find in peers table"); p = ao2_t_callback(peers, OBJ_POINTER, find_by_name, &tmp_peer, NULL, "ao2_find in peers table");
} else if (sin) { /* search by addr? */ } else if (sin) { /* search by addr? */
tmp_peer.addr.sin_addr.s_addr = sin->sin_addr.s_addr; tmp_peer.addr.sin_addr.s_addr = sin->sin_addr.s_addr;
tmp_peer.addr.sin_port = sin->sin_port; tmp_peer.addr.sin_port = sin->sin_port;
tmp_peer.flags[0].flags = 0; tmp_peer.flags[0].flags = 0;
p = ao2_t_find(peers_by_ip, &tmp_peer, OBJ_POINTER, "ao2_find in peers_by_ip table"); /* WAS: p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */ p = ao2_t_find(peers_by_ip, &tmp_peer, NULL, OBJ_POINTER, "ao2_find in peers_by_ip table"); /* WAS: p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */
if (!p) { if (!p) {
ast_set_flag(&tmp_peer.flags[0], SIP_INSECURE_PORT); ast_set_flag(&tmp_peer.flags[0], SIP_INSECURE_PORT);
p = ao2_t_find(peers_by_ip, &tmp_peer, OBJ_POINTER, "ao2_find in peers_by_ip table 2"); /* WAS: p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */ p = ao2_t_find(peers_by_ip, &tmp_peer, NULL, OBJ_POINTER, "ao2_find in peers_by_ip table 2"); /* WAS: p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */
if (p) { if (p) {
return p; return p;
} }
@ -6566,7 +6566,7 @@ struct find_call_cb_arg {
* code to determine whether this is the pvt that we are looking for. * code to determine whether this is the pvt that we are looking for.
* Return FALSE if not found, true otherwise. p is unlocked. * Return FALSE if not found, true otherwise. p is unlocked.
*/ */
static int find_call_cb(void *__pvt, void *__arg, int flags) static int find_call_cb(void *__pvt, void *__arg, void *data, int flags)
{ {
struct sip_pvt *p = __pvt; struct sip_pvt *p = __pvt;
struct find_call_cb_arg *arg = __arg; struct find_call_cb_arg *arg = __arg;
@ -6664,7 +6664,7 @@ restartsearch:
struct sip_pvt tmp_dialog = { struct sip_pvt tmp_dialog = {
.callid = callid, .callid = callid,
}; };
sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find in dialogs"); sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, NULL, OBJ_POINTER, "ao2_find in dialogs");
if (sip_pvt_ptr) { /* well, if we don't find it-- what IS in there? */ if (sip_pvt_ptr) { /* well, if we don't find it-- what IS in there? */
/* Found the call */ /* Found the call */
sip_pvt_lock(sip_pvt_ptr); sip_pvt_lock(sip_pvt_ptr);
@ -6672,7 +6672,7 @@ restartsearch:
} }
} else { /* in pedantic mode! -- do the fancy linear search */ } else { /* in pedantic mode! -- do the fancy linear search */
ao2_lock(dialogs); ao2_lock(dialogs);
p = ao2_t_callback(dialogs, 0 /* single, data */, find_call_cb, &arg, "pedantic linear search for dialog"); p = ao2_t_callback(dialogs, 0 /* single, data */, find_call_cb, &arg, NULL, "pedantic linear search for dialog");
if (p) { if (p) {
if (sip_pvt_trylock(p)) { if (sip_pvt_trylock(p)) {
ao2_unlock(dialogs); ao2_unlock(dialogs);
@ -12032,7 +12032,7 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
/* Search dialogs and find the match */ /* Search dialogs and find the match */
sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find of dialog in dialogs table"); sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, NULL, OBJ_POINTER, "ao2_find of dialog in dialogs table");
if (sip_pvt_ptr) { if (sip_pvt_ptr) {
/* Go ahead and lock it (and its owner) before returning */ /* Go ahead and lock it (and its owner) before returning */
sip_pvt_lock(sip_pvt_ptr); sip_pvt_lock(sip_pvt_ptr);
@ -13375,7 +13375,7 @@ static char *_sip_show_peers(int fd, int *total, struct mansession *s, const str
#undef FORMAT2 #undef FORMAT2
} }
static int peer_dump_func(void *userobj, void *arg, int flags) static int peer_dump_func(void *userobj, void *arg, void *data, int flags)
{ {
struct sip_peer *peer = userobj; struct sip_peer *peer = userobj;
int refc = ao2_t_ref(userobj, 0, ""); int refc = ao2_t_ref(userobj, 0, "");
@ -13386,7 +13386,7 @@ static int peer_dump_func(void *userobj, void *arg, int flags)
return 0; return 0;
} }
static int dialog_dump_func(void *userobj, void *arg, int flags) static int dialog_dump_func(void *userobj, void *arg, void *data, int flags)
{ {
struct sip_pvt *pvt = userobj; struct sip_pvt *pvt = userobj;
int refc = ao2_t_ref(userobj, 0, ""); int refc = ao2_t_ref(userobj, 0, "");
@ -13417,11 +13417,11 @@ static char *sip_show_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_a
if (a->argc != 3) if (a->argc != 3)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
ast_cli(a->fd, "-= Peer objects: %d static, %d realtime, %d autocreate =-\n\n", speerobjs, rpeerobjs, apeerobjs); ast_cli(a->fd, "-= Peer objects: %d static, %d realtime, %d autocreate =-\n\n", speerobjs, rpeerobjs, apeerobjs);
ao2_t_callback(peers, OBJ_NODATA, peer_dump_func, &a->fd, "initiate ao2_callback to dump peers"); ao2_t_callback(peers, OBJ_NODATA, peer_dump_func, &a->fd, NULL, "initiate ao2_callback to dump peers");
ast_cli(a->fd, "-= Registry objects: %d =-\n\n", regobjs); ast_cli(a->fd, "-= Registry objects: %d =-\n\n", regobjs);
ASTOBJ_CONTAINER_DUMP(a->fd, tmp, sizeof(tmp), &regl); ASTOBJ_CONTAINER_DUMP(a->fd, tmp, sizeof(tmp), &regl);
ast_cli(a->fd, "-= Dialog objects:\n\n"); ast_cli(a->fd, "-= Dialog objects:\n\n");
ao2_t_callback(dialogs, OBJ_NODATA, dialog_dump_func, &a->fd, "initiate ao2_callback to dump dialogs"); ao2_t_callback(dialogs, OBJ_NODATA, dialog_dump_func, &a->fd, NULL, "initiate ao2_callback to dump dialogs");
return CLI_SUCCESS; return CLI_SUCCESS;
} }
/*! \brief Print call group and pickup group */ /*! \brief Print call group and pickup group */
@ -13501,7 +13501,7 @@ static void cleanup_stale_contexts(char *new, char *old)
to be destroyed, toss it into the queue. Have a separate to be destroyed, toss it into the queue. Have a separate
thread do the locking and destruction */ thread do the locking and destruction */
static int dialog_needdestroy(void *dialogobj, void *arg, int flags) static int dialog_needdestroy(void *dialogobj, void *arg, void *data, int flags)
{ {
struct sip_pvt *dialog = dialogobj; struct sip_pvt *dialog = dialogobj;
time_t *t = arg; time_t *t = arg;
@ -13565,7 +13565,7 @@ static int dialog_needdestroy(void *dialogobj, void *arg, int flags)
/* this func is used with ao2_callback to unlink/delete all marked /* this func is used with ao2_callback to unlink/delete all marked
peers */ peers */
static int peer_is_marked(void *peerobj, void *arg, int flags) static int peer_is_marked(void *peerobj, void *arg, void *data, int flags)
{ {
struct sip_peer *peer = peerobj; struct sip_peer *peer = peerobj;
return peer->the_mark ? CMP_MATCH : 0; return peer->the_mark ? CMP_MATCH : 0;
@ -13672,7 +13672,7 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli
unref_peer(pi, "toss iterator peer ptr"); unref_peer(pi, "toss iterator peer ptr");
} }
if (pruned) { if (pruned) {
ao2_t_callback(peers, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, peer_is_marked, 0, ao2_t_callback(peers, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, peer_is_marked, NULL, NULL,
"initiating callback to remove marked peers"); "initiating callback to remove marked peers");
ast_cli(a->fd, "%d peers pruned.\n", pruned); ast_cli(a->fd, "%d peers pruned.\n", pruned);
} else } else
@ -13682,7 +13682,7 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli
if (prunepeer) { if (prunepeer) {
struct sip_peer tmp; struct sip_peer tmp;
ast_copy_string(tmp.name, name, sizeof(tmp.name)); ast_copy_string(tmp.name, name, sizeof(tmp.name));
if ((peer = ao2_t_find(peers, &tmp, OBJ_POINTER | OBJ_UNLINK, "finding to unlink from peers"))) { if ((peer = ao2_t_find(peers, &tmp, NULL, OBJ_POINTER | OBJ_UNLINK, "finding to unlink from peers"))) {
if (peer->addr.sin_addr.s_addr) { if (peer->addr.sin_addr.s_addr) {
ao2_t_unlink(peers_by_ip, peer, "unlinking peer from peers_by_ip also"); ao2_t_unlink(peers_by_ip, peer, "unlinking peer from peers_by_ip also");
} }
@ -14246,7 +14246,7 @@ static char *sip_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
} }
/*! \brief Callback for show_chanstats */ /*! \brief Callback for show_chanstats */
static int show_chanstats_cb(void *__cur, void *__arg, int flags) static int show_chanstats_cb(void *__cur, void *__arg, void *data, int flags)
{ {
#define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s (%-2.2s) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n" #define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s (%-2.2s) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n"
#define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u\n" #define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u\n"
@ -14325,7 +14325,7 @@ static char *sip_show_channelstats(struct ast_cli_entry *e, int cmd, struct ast_
ast_cli(a->fd, FORMAT2, "Peer", "Call ID", "Duration", "Recv: Pack", "Lost", "%", "Jitter", "Send: Pack", "Lost", "Jitter"); ast_cli(a->fd, FORMAT2, "Peer", "Call ID", "Duration", "Recv: Pack", "Lost", "%", "Jitter", "Send: Pack", "Lost", "Jitter");
/* iterate on the container and invoke the callback on each item */ /* iterate on the container and invoke the callback on each item */
ao2_t_callback(dialogs, OBJ_NODATA, show_chanstats_cb, &arg, "callback to sip show chanstats"); ao2_t_callback(dialogs, OBJ_NODATA, show_chanstats_cb, &arg, NULL, "callback to sip show chanstats");
ast_cli(a->fd, "%d active SIP channel%s\n", arg.numchans, (arg.numchans != 1) ? "s" : ""); ast_cli(a->fd, "%d active SIP channel%s\n", arg.numchans, (arg.numchans != 1) ? "s" : "");
return CLI_SUCCESS; return CLI_SUCCESS;
} }
@ -14600,7 +14600,7 @@ static const struct cfsubscription_types *find_subscription_type(enum subscripti
#define FORMAT "%-15.15s %-10.10s %-15.15s %-15.15s %-3.3s %-3.3s %-15.15s %-10.10s\n" #define FORMAT "%-15.15s %-10.10s %-15.15s %-15.15s %-3.3s %-3.3s %-15.15s %-10.10s\n"
/*! \brief callback for show channel|subscription */ /*! \brief callback for show channel|subscription */
static int show_channels_cb(void *__cur, void *__arg, int flags) static int show_channels_cb(void *__cur, void *__arg, void *data, int flags)
{ {
struct sip_pvt *cur = __cur; struct sip_pvt *cur = __cur;
struct __show_chan_arg *arg = __arg; struct __show_chan_arg *arg = __arg;
@ -14672,7 +14672,7 @@ static char *sip_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_
ast_cli(arg.fd, FORMAT3, "Peer", "User", "Call ID", "Extension", "Last state", "Type", "Mailbox", "Expiry"); ast_cli(arg.fd, FORMAT3, "Peer", "User", "Call ID", "Extension", "Last state", "Type", "Mailbox", "Expiry");
/* iterate on the container and invoke the callback on each item */ /* iterate on the container and invoke the callback on each item */
ao2_t_callback(dialogs, OBJ_NODATA, show_channels_cb, &arg, "callback to show channels"); ao2_t_callback(dialogs, OBJ_NODATA, show_channels_cb, &arg, NULL, "callback to show channels");
/* print summary information */ /* print summary information */
ast_cli(arg.fd, "%d active SIP %s%s\n", arg.numchans, ast_cli(arg.fd, "%d active SIP %s%s\n", arg.numchans,
@ -20616,7 +20616,7 @@ static void *do_monitor(void *data)
of time since the last time we did it (when MWI is being sent, we can of time since the last time we did it (when MWI is being sent, we can
get back to this point every millisecond or less) get back to this point every millisecond or less)
*/ */
ao2_t_callback(dialogs, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, dialog_needdestroy, &t, ao2_t_callback(dialogs, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, dialog_needdestroy, &t, NULL,
"callback to remove dialogs w/needdestroy"); "callback to remove dialogs w/needdestroy");
/* the old methodology would be to restart the search for dialogs to delete with every /* the old methodology would be to restart the search for dialogs to delete with every
@ -21826,7 +21826,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
during reload during reload
*/ */
ast_copy_string(tmp_peer.name, name, sizeof(tmp_peer.name)); ast_copy_string(tmp_peer.name, name, sizeof(tmp_peer.name));
peer = ao2_t_find(peers, &tmp_peer, OBJ_POINTER | OBJ_UNLINK, "find and unlink peer from peers table"); peer = ao2_t_find(peers, &tmp_peer, NULL, OBJ_POINTER | OBJ_UNLINK, "find and unlink peer from peers table");
} }
if (peer) { if (peer) {
@ -22268,7 +22268,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
return peer; return peer;
} }
static int peer_markall_func(void *device, void *arg, int flags) static int peer_markall_func(void *device, void *arg, void *data, int flags)
{ {
struct sip_peer *peer = device; struct sip_peer *peer = device;
peer->the_mark = 1; peer->the_mark = 1;
@ -22373,7 +22373,7 @@ static int reload_config(enum channelreloadreason reason)
/* Then, actually destroy users and registry */ /* Then, actually destroy users and registry */
ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy); ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
ast_debug(4, "--------------- Done destroying registry list\n"); ast_debug(4, "--------------- Done destroying registry list\n");
ao2_t_callback(peers, OBJ_NODATA, peer_markall_func, 0, "callback to mark all peers"); ao2_t_callback(peers, OBJ_NODATA, peer_markall_func, NULL, NULL, "callback to mark all peers");
} }
/* Reset certificate handling for TLS sessions */ /* Reset certificate handling for TLS sessions */
@ -23668,7 +23668,7 @@ static int sip_do_reload(enum channelreloadreason reason)
start_poke = time(0); start_poke = time(0);
/* Prune peers who still are supposed to be deleted */ /* Prune peers who still are supposed to be deleted */
ao2_t_callback(peers, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, peer_is_marked, 0, ao2_t_callback(peers, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, peer_is_marked, NULL, NULL,
"callback to remove marked peers"); "callback to remove marked peers");
ast_debug(4, "--------------- Done destroying pruned peers\n"); ast_debug(4, "--------------- Done destroying pruned peers\n");

@ -96,7 +96,7 @@ static int group_hash_fn(const void *obj, const int flags)
return ast_str_hash(g->name); return ast_str_hash(g->name);
} }
static int group_cmp_fn(void *obj1, void *name2, int flags) static int group_cmp_fn(void *obj1, void *name2, void *data, int flags)
{ {
struct group *g1 = obj1, *g2 = name2; struct group *g1 = obj1, *g2 = name2;
char *name = name2; char *name = name2;
@ -112,7 +112,7 @@ static int entry_hash_fn(const void *obj, const int flags)
return ast_str_hash(e->name); return ast_str_hash(e->name);
} }
static int entry_cmp_fn(void *obj1, void *name2, int flags) static int entry_cmp_fn(void *obj1, void *name2, void *data, int flags)
{ {
struct group_entry *e1 = obj1, *e2 = name2; struct group_entry *e1 = obj1, *e2 = name2;
char *name = name2; char *name = name2;
@ -125,7 +125,7 @@ static int entry_cmp_fn(void *obj1, void *name2, int flags)
static int dialgroup_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) static int dialgroup_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{ {
struct ao2_iterator i; struct ao2_iterator i;
struct group *grhead = ao2_find(group_container, data, 0); struct group *grhead = ao2_find(group_container, data, NULL, 0);
struct group_entry *entry; struct group_entry *entry;
size_t bufused = 0; size_t bufused = 0;
int trunc_warning = 0; int trunc_warning = 0;
@ -206,7 +206,7 @@ static int dialgroup_write(struct ast_channel *chan, const char *cmd, char *data
AST_STANDARD_APP_ARGS(args, data); AST_STANDARD_APP_ARGS(args, data);
AST_NONSTANDARD_APP_ARGS(inter, value, '&'); AST_NONSTANDARD_APP_ARGS(inter, value, '&');
if (!(grhead = ao2_find(group_container, args.group, 0))) { if (!(grhead = ao2_find(group_container, args.group, NULL, 0))) {
/* Create group */ /* Create group */
grhead = ao2_alloc(sizeof(*grhead), group_destroy); grhead = ao2_alloc(sizeof(*grhead), group_destroy);
if (!grhead) if (!grhead)
@ -245,7 +245,7 @@ static int dialgroup_write(struct ast_channel *chan, const char *cmd, char *data
} }
} else if (strncasecmp(args.op, "del", 3) == 0) { } else if (strncasecmp(args.op, "del", 3) == 0) {
for (j = 0; j < inter.argc; j++) { for (j = 0; j < inter.argc; j++) {
if ((entry = ao2_find(grhead->entries, inter.faces[j], OBJ_UNLINK))) { if ((entry = ao2_find(grhead->entries, inter.faces[j], NULL, OBJ_UNLINK))) {
ao2_ref(entry, -1); ao2_ref(entry, -1);
} else { } else {
ast_log(LOG_WARNING, "Interface '%s' not found in dialgroup '%s'\n", inter.faces[j], grhead->name); ast_log(LOG_WARNING, "Interface '%s' not found in dialgroup '%s'\n", inter.faces[j], grhead->name);

@ -589,7 +589,7 @@ to define callback and hash functions and their arguments.
* The return values are a combination of enum _cb_results. * The return values are a combination of enum _cb_results.
* Callback functions are used to search or manipulate objects in a container, * Callback functions are used to search or manipulate objects in a container,
*/ */
typedef int (ao2_callback_fn)(void *obj, void *arg, int flags); typedef int (ao2_callback_fn)(void *obj, void *arg, void *data, int flags);
/*! \brief a very common callback is one that matches by address. */ /*! \brief a very common callback is one that matches by address. */
ao2_callback_fn ao2_match_by_addr; ao2_callback_fn ao2_match_by_addr;
@ -822,31 +822,31 @@ struct ao2_list {
* be used to free the additional reference possibly created by this function. * be used to free the additional reference possibly created by this function.
*/ */
#ifdef REF_DEBUG #ifdef REF_DEBUG
#define ao2_t_callback(arg1,arg2,arg3,arg4,arg5) _ao2_callback_debug((arg1), (arg2), (arg3), (arg4), (arg5), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_t_callback(arg1,arg2,arg3,arg4,arg5,arg6) _ao2_callback_debug((arg1), (arg2), (arg3), (arg4), (arg5), (arg6), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_callback(arg1,arg2,arg3,arg4) _ao2_callback_debug((arg1), (arg2), (arg3), (arg4), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_callback(arg1,arg2,arg3,arg4,arg5) _ao2_callback_debug((arg1), (arg2), (arg3), (arg4), (arg5), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
#else #else
#define ao2_t_callback(arg1,arg2,arg3,arg4,arg5) _ao2_callback((arg1), (arg2), (arg3), (arg4)) #define ao2_t_callback(arg1,arg2,arg3,arg4,arg5,arg6) _ao2_callback((arg1), (arg2), (arg3), (arg4), (arg5))
#define ao2_callback(arg1,arg2,arg3,arg4) _ao2_callback((arg1), (arg2), (arg3), (arg4)) #define ao2_callback(arg1,arg2,arg3,arg4,arg5) _ao2_callback((arg1), (arg2), (arg3), (arg4), (arg5))
#endif #endif
void *_ao2_callback_debug(struct ao2_container *c, enum search_flags flags, void *_ao2_callback_debug(struct ao2_container *c, enum search_flags flags,
ao2_callback_fn *cb_fn, void *arg, char *tag, ao2_callback_fn *cb_fn, void *arg, void *data, char *tag,
char *file, int line, const char *funcname); char *file, int line, const char *funcname);
void *_ao2_callback(struct ao2_container *c, void *_ao2_callback(struct ao2_container *c,
enum search_flags flags, enum search_flags flags,
ao2_callback_fn *cb_fn, void *arg); ao2_callback_fn *cb_fn, void *arg, void *data);
/*! ao2_find() is a short hand for ao2_callback(c, flags, c->cmp_fn, arg) /*! ao2_find() is a short hand for ao2_callback(c, flags, c->cmp_fn, arg)
* XXX possibly change order of arguments ? * XXX possibly change order of arguments ?
*/ */
#ifdef REF_DEBUG #ifdef REF_DEBUG
#define ao2_t_find(arg1,arg2,arg3,arg4) _ao2_find_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_t_find(arg1,arg2,arg3,arg4,arg5) _ao2_find_debug((arg1), (arg2), (arg3), (arg4), (arg5), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_find(arg1,arg2,arg3) _ao2_find_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__) #define ao2_find(arg1,arg2,arg3,arg4) _ao2_find_debug((arg1), (arg2), (arg3), (arg4), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
#else #else
#define ao2_t_find(arg1,arg2,arg3,arg4) _ao2_find((arg1), (arg2), (arg3)) #define ao2_t_find(arg1,arg2,arg3,arg4,arg5) _ao2_find((arg1), (arg2), (arg3), (arg4))
#define ao2_find(arg1,arg2,arg3) _ao2_find((arg1), (arg2), (arg3)) #define ao2_find(arg1,arg2,arg3,arg4) _ao2_find((arg1), (arg2), (arg3), (arg4))
#endif #endif
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_find_debug(struct ao2_container *c, void *arg, void *data, enum search_flags flags, char *tag, char *file, int line, const char *funcname);
void *_ao2_find(struct ao2_container *c, void *arg, enum search_flags flags); void *_ao2_find(struct ao2_container *c, void *arg, void *data, enum search_flags flags);
/*! \brief /*! \brief
* *

@ -135,7 +135,7 @@ static struct ao2_container *__ao2_container_alloc(struct ao2_container *c, cons
ao2_callback_fn *cmp_fn); ao2_callback_fn *cmp_fn);
static struct bucket_list *__ao2_link(struct ao2_container *c, void *user_data); static struct bucket_list *__ao2_link(struct ao2_container *c, void *user_data);
static void *__ao2_callback(struct ao2_container *c, static void *__ao2_callback(struct ao2_container *c,
const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, void *data,
char *tag, char *file, int line, const char *funcname); char *tag, char *file, int line, const char *funcname);
static void * __ao2_iterator_next(struct ao2_iterator *a, struct bucket_list **q); static void * __ao2_iterator_next(struct ao2_iterator *a, struct bucket_list **q);
@ -511,7 +511,7 @@ void *_ao2_link(struct ao2_container *c, void *user_data)
/*! /*!
* \brief another convenience function is a callback that matches on address * \brief another convenience function is a callback that matches on address
*/ */
int ao2_match_by_addr(void *user_data, void *arg, int flags) int ao2_match_by_addr(void *user_data, void *arg, void *data, int flags)
{ {
return (user_data == arg) ? (CMP_MATCH | CMP_STOP) : 0; return (user_data == arg) ? (CMP_MATCH | CMP_STOP) : 0;
} }
@ -526,7 +526,7 @@ void *_ao2_unlink_debug(struct ao2_container *c, void *user_data, char *tag,
if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */ if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */
return NULL; return NULL;
_ao2_callback_debug(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data, tag, file, line, funcname); _ao2_callback_debug(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data, NULL, tag, file, line, funcname);
return NULL; return NULL;
} }
@ -536,7 +536,7 @@ void *_ao2_unlink(struct ao2_container *c, void *user_data)
if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */ if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */
return NULL; return NULL;
_ao2_callback(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data); _ao2_callback(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data, NULL);
return NULL; return NULL;
} }
@ -544,7 +544,7 @@ void *_ao2_unlink(struct ao2_container *c, void *user_data)
/*! /*!
* \brief special callback that matches all * \brief special callback that matches all
*/ */
static int cb_true(void *user_data, void *arg, int flags) static int cb_true(void *user_data, void *arg, void *data, int flags)
{ {
ast_log(LOG_ERROR,"If you see this, something is strange!\n"); ast_log(LOG_ERROR,"If you see this, something is strange!\n");
return CMP_MATCH; return CMP_MATCH;
@ -559,7 +559,7 @@ static int cb_true(void *user_data, void *arg, int flags)
* called as often as, say, the ao2_ref func is called. * called as often as, say, the ao2_ref func is called.
*/ */
static void *__ao2_callback(struct ao2_container *c, static void *__ao2_callback(struct ao2_container *c,
const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, void *data,
char *tag, char *file, int line, const char *funcname) char *tag, char *file, int line, const char *funcname)
{ {
int i, last; /* search boundaries */ int i, last; /* search boundaries */
@ -602,7 +602,7 @@ static void *__ao2_callback(struct ao2_container *c,
struct bucket_list *cur; struct bucket_list *cur;
AST_LIST_TRAVERSE_SAFE_BEGIN(&c->buckets[i], cur, entry) { AST_LIST_TRAVERSE_SAFE_BEGIN(&c->buckets[i], cur, entry) {
int match = cb_fn(EXTERNAL_OBJ(cur->astobj), arg, flags) & (CMP_MATCH | CMP_STOP); int match = cb_fn(EXTERNAL_OBJ(cur->astobj), arg, data, flags) & (CMP_MATCH | CMP_STOP);
/* we found the object, performing operations according flags */ /* we found the object, performing operations according flags */
if (match == 0) { /* no match, no stop, continue */ if (match == 0) { /* no match, no stop, continue */
@ -658,29 +658,29 @@ static void *__ao2_callback(struct ao2_container *c,
void *_ao2_callback_debug(struct ao2_container *c, void *_ao2_callback_debug(struct ao2_container *c,
const enum search_flags flags, const enum search_flags flags,
ao2_callback_fn *cb_fn, void *arg, ao2_callback_fn *cb_fn, void *arg, void *data,
char *tag, char *file, int line, const char *funcname) char *tag, char *file, int line, const char *funcname)
{ {
return __ao2_callback(c,flags, cb_fn, arg, tag, file, line, funcname); return __ao2_callback(c,flags, cb_fn, arg, data, tag, file, line, funcname);
} }
void *_ao2_callback(struct ao2_container *c,const enum search_flags flags, void *_ao2_callback(struct ao2_container *c,const enum search_flags flags,
ao2_callback_fn *cb_fn, void *arg) ao2_callback_fn *cb_fn, void *arg, void *data)
{ {
return __ao2_callback(c,flags, cb_fn, arg, NULL, NULL, 0, NULL); return __ao2_callback(c,flags, cb_fn, arg, data, NULL, NULL, 0, NULL);
} }
/*! /*!
* the find function just invokes the default callback with some reasonable flags. * the find function just invokes the default callback with some reasonable 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_find_debug(struct ao2_container *c, void *arg, void *data, enum search_flags flags, char *tag, char *file, int line, const char *funcname)
{ {
return _ao2_callback_debug(c, flags, c->cmp_fn, arg, tag, file, line, funcname); return _ao2_callback_debug(c, flags, c->cmp_fn, arg, data, tag, file, line, funcname);
} }
void *_ao2_find(struct ao2_container *c, void *arg, enum search_flags flags) void *_ao2_find(struct ao2_container *c, void *arg, void *data, enum search_flags flags)
{ {
return _ao2_callback(c, flags, c->cmp_fn, arg); return _ao2_callback(c, flags, c->cmp_fn, arg, data);
} }
/*! /*!
@ -793,13 +793,13 @@ void * _ao2_iterator_next(struct ao2_iterator *a)
/* callback for destroying container. /* callback for destroying container.
* we can make it simple as we know what it does * we can make it simple as we know what it does
*/ */
static int cd_cb(void *obj, void *arg, int flag) static int cd_cb(void *obj, void *arg, void *data, int flag)
{ {
_ao2_ref(obj, -1); _ao2_ref(obj, -1);
return 0; return 0;
} }
static int cd_cb_debug(void *obj, void *arg, int flag) static int cd_cb_debug(void *obj, void *arg, void *data, int flag)
{ {
_ao2_ref_debug(obj, -1, "deref object via container destroy", __FILE__, __LINE__, __PRETTY_FUNCTION__); _ao2_ref_debug(obj, -1, "deref object via container destroy", __FILE__, __LINE__, __PRETTY_FUNCTION__);
return 0; return 0;
@ -810,7 +810,7 @@ static void container_destruct(void *_c)
struct ao2_container *c = _c; struct ao2_container *c = _c;
int i; int i;
_ao2_callback(c, OBJ_UNLINK, cd_cb, NULL); _ao2_callback(c, OBJ_UNLINK, cd_cb, NULL, NULL);
for (i = 0; i < c->n_buckets; i++) { for (i = 0; i < c->n_buckets; i++) {
struct bucket_list *current; struct bucket_list *current;
@ -830,7 +830,7 @@ static void container_destruct_debug(void *_c)
struct ao2_container *c = _c; struct ao2_container *c = _c;
int i; int i;
_ao2_callback_debug(c, OBJ_UNLINK, cd_cb_debug, NULL, "container_destruct_debug called", __FILE__, __LINE__, __PRETTY_FUNCTION__); _ao2_callback_debug(c, OBJ_UNLINK, cd_cb_debug, NULL, NULL, "container_destruct_debug called", __FILE__, __LINE__, __PRETTY_FUNCTION__);
for (i = 0; i < c->n_buckets; i++) { for (i = 0; i < c->n_buckets; i++) {
struct bucket_list *current; struct bucket_list *current;
@ -846,7 +846,7 @@ static void container_destruct_debug(void *_c)
} }
#ifdef AO2_DEBUG #ifdef AO2_DEBUG
static int print_cb(void *obj, void *arg, int flag) static int print_cb(void *obj, void *arg, void *data, int flag)
{ {
int *fd = arg; int *fd = arg;
char *s = (char *)obj; char *s = (char *)obj;
@ -938,7 +938,7 @@ static char *handle_astobj2_test(struct ast_cli_entry *e, int cmd, struct ast_cl
ao2_t_ref(obj, -1, "test"); ao2_t_ref(obj, -1, "test");
} }
ast_cli(a->fd, "testing callbacks\n"); ast_cli(a->fd, "testing callbacks\n");
ao2_t_callback(c1, 0, print_cb, &a->fd,"test callback"); ao2_t_callback(c1, 0, print_cb, &a->fd, NULL, "test callback");
ast_cli(a->fd, "testing iterators, remove every second object\n"); ast_cli(a->fd, "testing iterators, remove every second object\n");
{ {
struct ao2_iterator ai; struct ao2_iterator ai;
@ -959,7 +959,7 @@ static char *handle_astobj2_test(struct ast_cli_entry *e, int cmd, struct ast_cl
} }
} }
ast_cli(a->fd, "testing callbacks again\n"); ast_cli(a->fd, "testing callbacks again\n");
ao2_t_callback(c1, 0, print_cb, &a->fd,"test callback"); ao2_t_callback(c1, 0, print_cb, &a->fd, NULL, "test callback");
ast_verbose("now you should see an error message:\n"); ast_verbose("now you should see an error message:\n");
ao2_t_ref(&i, -1, ""); /* i is not a valid object so we print an error here */ ao2_t_ref(&i, -1, ""); /* i is not a valid object so we print an error here */

@ -149,7 +149,7 @@ static int hash_string(const void *obj, const int flags)
return total; return total;
} }
static int hashtab_compare_strings(void *a, void *b, int flags) static int hashtab_compare_strings(void *a, void *b, void *data, int flags)
{ {
const struct inclfile *ae = a, *be = b; const struct inclfile *ae = a, *be = b;
return !strcmp(ae->fname, be->fname) ? CMP_MATCH | CMP_STOP : 0; return !strcmp(ae->fname, be->fname) ? CMP_MATCH | CMP_STOP : 0;
@ -1509,7 +1509,7 @@ static void set_fn(char *fn, int fn_size, const char *file, const char *configfi
else else
snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file); snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file);
lookup.fname = fn; lookup.fname = fn;
*fi = ao2_find(fileset, &lookup, OBJ_POINTER); *fi = ao2_find(fileset, &lookup, NULL, OBJ_POINTER);
if (!(*fi)) { if (!(*fi)) {
/* set up a file scratch pad */ /* set up a file scratch pad */
struct inclfile *fx = ao2_alloc(sizeof(struct inclfile), inclfile_destroy); struct inclfile *fx = ao2_alloc(sizeof(struct inclfile), inclfile_destroy);

@ -295,7 +295,7 @@ static int parkinglot_hash_cb(const void *obj, const int flags)
return ast_str_hash(parkinglot->name); return ast_str_hash(parkinglot->name);
} }
static int parkinglot_cmp_cb(void *obj, void *arg, int flags) static int parkinglot_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct ast_parkinglot *parkinglot = obj, *parkinglot2 = arg; struct ast_parkinglot *parkinglot = obj, *parkinglot2 = arg;
return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH | CMP_STOP : 0; return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH | CMP_STOP : 0;
@ -2838,7 +2838,7 @@ struct ast_parkinglot *find_parkinglot(const char *name)
ast_copy_string(tmp_parkinglot.name, name, sizeof(tmp_parkinglot.name)); ast_copy_string(tmp_parkinglot.name, name, sizeof(tmp_parkinglot.name));
parkinglot = ao2_find(parkinglots, &tmp_parkinglot, OBJ_POINTER); parkinglot = ao2_find(parkinglots, &tmp_parkinglot, NULL, OBJ_POINTER);
if (parkinglot && option_debug) if (parkinglot && option_debug)
ast_log(LOG_DEBUG, "Found Parkinglot: %s\n", parkinglot->name); ast_log(LOG_DEBUG, "Found Parkinglot: %s\n", parkinglot->name);

@ -3558,7 +3558,7 @@ static int variable_count_hash_fn(const void *vvc, const int flags)
return res; return res;
} }
static int variable_count_cmp_fn(void *obj, void *vstr, int flags) static int variable_count_cmp_fn(void *obj, void *vstr, void *data, int flags)
{ {
/* Due to the simplicity of struct variable_count, it makes no difference /* Due to the simplicity of struct variable_count, it makes no difference
* if you pass in objects or strings, the same operation applies. This is * if you pass in objects or strings, the same operation applies. This is
@ -3667,7 +3667,7 @@ static void xml_translate(struct ast_str **out, char *in, struct ast_variable *v
if (!in_data) { /* build appropriate line start */ if (!in_data) { /* build appropriate line start */
ast_str_append(out, 0, xml ? " " : "<tr><td>"); ast_str_append(out, 0, xml ? " " : "<tr><td>");
if ((vc = ao2_find(vco, var, 0))) if ((vc = ao2_find(vco, var, NULL, 0)))
vc->count++; vc->count++;
else { else {
/* Create a new entry for this one */ /* Create a new entry for this one */

@ -93,7 +93,7 @@ AST_MUTEX_DEFINE_STATIC(cli_ping_cond_lock);
/*! \brief The astobj2 hash callback for taskprocessors */ /*! \brief The astobj2 hash callback for taskprocessors */
static int tps_hash_cb(const void *obj, const int flags); static int tps_hash_cb(const void *obj, const int flags);
/*! \brief The astobj2 compare callback for taskprocessors */ /*! \brief The astobj2 compare callback for taskprocessors */
static int tps_cmp_cb(void *obj, void *arg, int flags); static int tps_cmp_cb(void *obj, void *arg, void *data, int flags);
/*! \brief The task processing function executed by a taskprocessor */ /*! \brief The task processing function executed by a taskprocessor */
static void *tps_processing_function(void *data); static void *tps_processing_function(void *data);
@ -335,7 +335,7 @@ static int tps_hash_cb(const void *obj, const int flags)
} }
/* compare callback for astobj2 */ /* compare callback for astobj2 */
static int tps_cmp_cb(void *obj, void *arg, int flags) static int tps_cmp_cb(void *obj, void *arg, void *data, int flags)
{ {
struct ast_taskprocessor *lhs = obj, *rhs = arg; struct ast_taskprocessor *lhs = obj, *rhs = arg;
@ -415,7 +415,7 @@ struct ast_taskprocessor *ast_taskprocessor_get(char *name, enum ast_tps_options
return NULL; return NULL;
} }
ao2_lock(tps_singletons); ao2_lock(tps_singletons);
p = ao2_find(tps_singletons, &tmp_tps, OBJ_POINTER); p = ao2_find(tps_singletons, &tmp_tps, NULL, OBJ_POINTER);
if (p) { if (p) {
ao2_unlock(tps_singletons); ao2_unlock(tps_singletons);
return p; return p;

@ -236,7 +236,7 @@ static struct phone_profile *find_profile(const char *name)
.name = name, .name = name,
}; };
return ao2_find(profiles, &tmp, OBJ_POINTER); return ao2_find(profiles, &tmp, NULL, OBJ_POINTER);
} }
static int profile_hash_fn(const void *obj, const int flags) static int profile_hash_fn(const void *obj, const int flags)
@ -246,7 +246,7 @@ static int profile_hash_fn(const void *obj, const int flags)
return ast_str_hash(profile->name); return ast_str_hash(profile->name);
} }
static int profile_cmp_fn(void *obj, void *arg, int flags) static int profile_cmp_fn(void *obj, void *arg, void *data, int flags)
{ {
const struct phone_profile *profile1 = obj, *profile2 = arg; const struct phone_profile *profile1 = obj, *profile2 = arg;
@ -299,7 +299,7 @@ static int routes_hash_fn(const void *obj, const int flags)
return ast_str_hash(uri); return ast_str_hash(uri);
} }
static int routes_cmp_fn(void *obj, void *arg, int flags) static int routes_cmp_fn(void *obj, void *arg, void *data, int flags)
{ {
const struct http_route *route1 = obj, *route2 = arg; const struct http_route *route1 = obj, *route2 = arg;
@ -419,7 +419,7 @@ static struct ast_str *phoneprov_callback(struct ast_tcptls_session_instance *se
struct timeval now = ast_tvnow(); struct timeval now = ast_tvnow();
struct ast_tm tm; struct ast_tm tm;
if (!(route = ao2_find(http_routes, &search_route, OBJ_POINTER))) { if (!(route = ao2_find(http_routes, &search_route, NULL, OBJ_POINTER))) {
goto out404; goto out404;
} }
@ -780,7 +780,7 @@ static struct user *find_user(const char *macaddress)
.macaddress = macaddress, .macaddress = macaddress,
}; };
return ao2_find(users, &tmp, OBJ_POINTER); return ao2_find(users, &tmp, NULL, OBJ_POINTER);
} }
static int users_hash_fn(const void *obj, const int flags) static int users_hash_fn(const void *obj, const int flags)
@ -797,7 +797,7 @@ static int users_hash_fn(const void *obj, const int flags)
return ast_str_hash(mac); return ast_str_hash(mac);
} }
static int users_cmp_fn(void *obj, void *arg, int flags) static int users_cmp_fn(void *obj, void *arg, void *data, int flags)
{ {
const struct user *user1 = obj, *user2 = arg; const struct user *user1 = obj, *user2 = arg;

@ -268,7 +268,7 @@ static struct pthread_timer *find_timer(int handle, int unlinkobj)
flags |= OBJ_UNLINK; flags |= OBJ_UNLINK;
} }
if (!(timer = ao2_find(pthread_timers, &tmp_timer, flags))) { if (!(timer = ao2_find(pthread_timers, &tmp_timer, NULL, flags))) {
ast_assert(timer != NULL); ast_assert(timer != NULL);
return NULL; return NULL;
} }
@ -304,7 +304,7 @@ static int pthread_timer_hash(const void *obj, const int flags)
/*! /*!
* \note only PIPE_READ is guaranteed valid * \note only PIPE_READ is guaranteed valid
*/ */
static int pthread_timer_cmp(void *obj, void *arg, int flags) static int pthread_timer_cmp(void *obj, void *arg, void *data, int flags)
{ {
struct pthread_timer *timer1 = obj, *timer2 = arg; struct pthread_timer *timer1 = obj, *timer2 = arg;
@ -396,7 +396,7 @@ static void write_byte(int wr_fd)
} while (0); } while (0);
} }
static int run_timer(void *obj, void *arg, int flags) static int run_timer(void *obj, void *arg, void *data, int flags)
{ {
struct pthread_timer *timer = obj; struct pthread_timer *timer = obj;
@ -422,7 +422,7 @@ static void *do_timing(void *arg)
while (!timing_thread.stop) { while (!timing_thread.stop) {
struct timespec ts = { 0, }; struct timespec ts = { 0, };
ao2_callback(pthread_timers, OBJ_NODATA, run_timer, NULL); ao2_callback(pthread_timers, OBJ_NODATA, run_timer, NULL, NULL);
next_wakeup = ast_tvadd(next_wakeup, ast_tv(0, 5000)); next_wakeup = ast_tvadd(next_wakeup, ast_tv(0, 5000));

@ -80,7 +80,7 @@ static int hash_string(const void *obj, const int flags)
return total; return total;
} }
static int hashtab_compare_strings(void *a, void *b, int flags) static int hashtab_compare_strings(void *a, void *b, void *data, int flags)
{ {
const struct ht_element *ae = a, *be = b; const struct ht_element *ae = a, *be = b;
return !strcmp(ae->key, be->key) ? CMP_MATCH | CMP_STOP : 0; return !strcmp(ae->key, be->key) ? CMP_MATCH | CMP_STOP : 0;
@ -137,7 +137,7 @@ static void add_element(void)
els_added++; /* unprotected, sometimes off, but, not really important, either */ els_added++; /* unprotected, sometimes off, but, not really important, either */
} }
static int do_nothing_cb(void *obj, void *arg, int flags) static int do_nothing_cb(void *obj, void *arg, void *data, int flags)
{ {
return 0; return 0;
} }
@ -147,7 +147,7 @@ static void traverse_elements(void)
#ifdef DEBUG #ifdef DEBUG
printf("Traverse hashtab\n"); printf("Traverse hashtab\n");
#endif #endif
ao2_callback(glob_hashtab, OBJ_NODATA, do_nothing_cb, NULL); ao2_callback(glob_hashtab, OBJ_NODATA, do_nothing_cb, NULL, NULL);
els_traversals++; /* unprotected, sometimes off, but, not really important, either */ els_traversals++; /* unprotected, sometimes off, but, not really important, either */
} }
@ -164,7 +164,7 @@ static void * del_element(unsigned int *seedp)
printf("- %s", keybuf); printf("- %s", keybuf);
#endif #endif
lookup.key = keybuf; lookup.key = keybuf;
el = ao2_find(glob_hashtab, &lookup, OBJ_POINTER); el = ao2_find(glob_hashtab, &lookup, NULL, OBJ_POINTER);
if (el) { if (el) {
#ifdef DEBUG #ifdef DEBUG
printf("...YES (el=%x)\n", (unsigned long)el); printf("...YES (el=%x)\n", (unsigned long)el);
@ -190,7 +190,7 @@ static int lookup_element(unsigned int *seedp)
x = my_rand(0,glob_highwater-1,seedp); x = my_rand(0,glob_highwater-1,seedp);
sprintf(keybuf, "key%08d", x); sprintf(keybuf, "key%08d", x);
lookup.key = keybuf; lookup.key = keybuf;
el = ao2_find(glob_hashtab, &lookup, OBJ_POINTER); el = ao2_find(glob_hashtab, &lookup, NULL, OBJ_POINTER);
els_lookedup++; els_lookedup++;
if (el) { if (el) {
els_found++; els_found++;

Loading…
Cancel
Save