Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 150122) +++ apps/app_queue.c (working copy) @@ -67,6 +67,7 @@ #include #include #include +#include #include "asterisk/lock.h" #include "asterisk/file.h" @@ -555,7 +556,13 @@ static int queue_hash_cb(const void *obj, const int flags) { const struct call_queue *q = obj; - return ast_str_hash(q->name); + char *lower_name = ast_strdupa(q->name); + int i; + + for (i = 0; i < strlen(lower_name); ++i) { + lower_name[i] = tolower(lower_name[i]); + } + return ast_str_hash(lower_name); } static int queue_cmp_cb(void *obj, void *arg, int flags) @@ -1469,7 +1476,6 @@ /* Delete if unused (else will be deleted when last caller leaves). */ ao2_unlink(queues, q); ao2_unlock(q); - queue_unref(q); } return NULL; } @@ -1964,8 +1970,6 @@ if (q->dead) { /* It's dead and nobody is in it, so kill it */ ao2_unlink(queues, q); - /* unref the container's reference to the queue */ - queue_unref(q); } /* unref the explicit ref earlier in the function */ queue_unref(q); @@ -2020,11 +2024,10 @@ } } ao2_unlock(q); + queue_unref(q); if (found) { - queue_unref(q); break; } - queue_unref(q); } return found; } @@ -3904,6 +3907,8 @@ if (!mem->dynamic) { ao2_ref(mem, -1); ao2_unlock(q); + queue_unref(q); + ao2_unlock(queues); return RES_NOT_DYNAMIC; } q->membercount--; @@ -5442,13 +5447,15 @@ } } - queue_iter = ao2_iterator_init(queues, 0); + queue_iter = ao2_iterator_init(queues, F_AO2I_DONTLOCK); + ao2_lock(queues); while ((q = ao2_iterator_next(&queue_iter))) { float sl; ao2_lock(q); if (argc == 3 && strcasecmp(q->name, argv[2])) { ao2_unlock(q); + queue_unref(q); continue; } found = 1; @@ -5519,6 +5526,7 @@ } queue_unref(q); /* Unref the iterator's reference */ } + ao2_unlock(queues); if (!found) { if (argc == 3) ast_str_set(&out, 0, "No such queue: %s.", argv[2]);