mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
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
This commit is contained in:
@@ -853,7 +853,7 @@ static int queue_hash_cb(const void *obj, const int flags)
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
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. */
|
||||
|
||||
/* Static queues override realtime. */
|
||||
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) {
|
||||
if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
|
||||
ao2_lock(q);
|
||||
if (!q->realtime) {
|
||||
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. */
|
||||
q = ao2_find(queues, &tmpq, OBJ_POINTER);
|
||||
q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER);
|
||||
|
||||
if (!q || q->realtime) {
|
||||
/*! \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);
|
||||
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);
|
||||
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);
|
||||
@@ -3128,7 +3128,7 @@ static int update_queue(struct call_queue *q, struct member *member, int callcom
|
||||
queue_iter = ao2_iterator_init(queues, 0);
|
||||
while ((qtmp = ao2_iterator_next(&queue_iter))) {
|
||||
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);
|
||||
mem->calls++;
|
||||
mem->lastqueue = q;
|
||||
@@ -4175,10 +4175,10 @@ static int remove_from_queue(const char *queuename, const char *interface)
|
||||
int res = RES_NOSUCHQUEUE;
|
||||
|
||||
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(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!! */
|
||||
if (!mem->dynamic) {
|
||||
ao2_ref(mem, -1);
|
||||
@@ -4401,7 +4401,7 @@ static int get_member_penalty(char *queuename, char *interface)
|
||||
};
|
||||
struct member *mem;
|
||||
|
||||
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) {
|
||||
if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
|
||||
foundqueue = 1;
|
||||
ao2_lock(q);
|
||||
if ((mem = interface_exists(q, interface))) {
|
||||
@@ -4453,7 +4453,7 @@ static void reload_queue_members(void)
|
||||
struct call_queue tmpq = {
|
||||
.name = queue_name,
|
||||
};
|
||||
cur_queue = ao2_find(queues, &tmpq, OBJ_POINTER);
|
||||
cur_queue = ao2_find(queues, &tmpq, NULL, OBJ_POINTER);
|
||||
}
|
||||
|
||||
if (!cur_queue)
|
||||
@@ -5077,7 +5077,7 @@ static int queue_function_var(struct ast_channel *chan, const char *cmd, char *d
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) {
|
||||
if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
|
||||
ao2_lock(q);
|
||||
if (q->setqueuevar) {
|
||||
sl = 0;
|
||||
@@ -5218,7 +5218,7 @@ static int queue_function_queuewaitingcount(struct ast_channel *chan, const char
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) {
|
||||
if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
|
||||
ao2_lock(q);
|
||||
count = q->count;
|
||||
ao2_unlock(q);
|
||||
@@ -5254,7 +5254,7 @@ static int queue_function_queuememberlist(struct ast_channel *chan, const char *
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) {
|
||||
if ((q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
|
||||
int buflen = 0, count = 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 = {
|
||||
.name = cat,
|
||||
};
|
||||
if (!(q = ao2_find(queues, &tmpq, OBJ_POINTER))) {
|
||||
if (!(q = ao2_find(queues, &tmpq, NULL, OBJ_POINTER))) {
|
||||
/* Make one then */
|
||||
if (!(q = alloc_queue(cat))) {
|
||||
/* TODO: Handle memory allocation failure */
|
||||
@@ -5589,7 +5589,7 @@ static int reload_queues(int reload)
|
||||
|
||||
/* Find the old position in the list */
|
||||
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);
|
||||
ao2_link(q->members, newm);
|
||||
ao2_ref(newm, -1);
|
||||
|
Reference in New Issue
Block a user