Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 91598) +++ apps/app_queue.c (working copy) @@ -308,6 +308,7 @@ time_t last_pos; /*!< Last time we told the user their position */ int opos; /*!< Where we started in the queue */ int handled; /*!< Whether our call was handled */ + int pending; /*!< Non-zero if we are attempting to call a member */ int max_penalty; /*!< Limit the members that can take this call to this penalty or lower */ time_t start; /*!< When we started holding */ time_t expire; /*!< When this entry should expire (time out of queue) */ @@ -2320,7 +2321,7 @@ if (option_debug) ast_log(LOG_DEBUG, "There are %d available members.\n", avl); - while ((idx < avl) && (ch) && (ch != qe)) { + while ((idx < avl) && (ch) && !ch->pending && (ch != qe)) { idx++; ch = ch->next; } @@ -2636,6 +2637,7 @@ to = (qe->expire - now) * 1000; else to = (qe->parent->timeout) ? qe->parent->timeout * 1000 : -1; + ++qe->pending; ring_one(qe, outgoing, &numbusies); ast_mutex_unlock(&qe->parent->lock); if (use_weight) @@ -2650,6 +2652,7 @@ ast_mutex_unlock(&qe->parent->lock); peer = lpeer ? lpeer->chan : NULL; if (!peer) { + qe->pending = 0; if (to) { /* Must gotten hung up */ res = -1;