diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-11-08 04:35:57 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-11-08 04:35:57 +0000 |
commit | 5a55a162d7d811f3bf31ef8247fc9b900e6237da (patch) | |
tree | fdfad07246db3043991f439140faab2a260dcfd4 /apps/app_queue.c | |
parent | 578e6fddfeec4b995b24137b1fae772619a42f8c (diff) |
Trustingly add Thorston's deadlock patch
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1708 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_queue.c')
-rwxr-xr-x | apps/app_queue.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c index 1c3ab73b2..ee004f429 100755 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -609,10 +609,8 @@ static int wait_our_turn(struct queue_ent *qe) struct queue_ent *ch; int res = 0; for (;;) { - /* Atomically read the parent head */ - ast_mutex_lock(&qe->parent->lock); + /* Atomically read the parent head -- does not need a lock */ ch = qe->parent->head; - ast_mutex_unlock(&qe->parent->lock); /* If we are now at the top of the head, break out */ if (qe->parent->head == qe) break; @@ -722,6 +720,7 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri /* Get a technology/[device:]number pair */ tmp = malloc(sizeof(struct localuser)); if (!tmp) { + ast_mutex_unlock(&qe->parent->lock); ast_log(LOG_WARNING, "Out of memory\n"); goto out; } @@ -859,11 +858,8 @@ out: static int wait_a_bit(struct queue_ent *qe) { - int retrywait; - /* Hold the lock while we setup the outgoing calls */ - ast_mutex_lock(&qe->parent->lock); - retrywait = qe->parent->retry * 1000; - ast_mutex_unlock(&qe->parent->lock); + /* Don't need to hold the lock while we setup the outgoing calls */ + int retrywait = qe->parent->retry * 1000; return ast_waitfordigit(qe->chan, retrywait); } @@ -1203,6 +1199,7 @@ static void reload_queues(void) /* Mark all queues as dead for the moment */ q = queues; while(q) { + q->dead = 1; q = q->next; } /* Chug through config file */ @@ -1349,8 +1346,10 @@ static int queues_show(int fd, int argc, char **argv) time(&now); if (argc != 2) return RESULT_SHOWUSAGE; + ast_mutex_lock(&qlock); q = queues; if (!q) { + ast_mutex_unlock(&qlock); ast_cli(fd, "No queues.\n"); return RESULT_SUCCESS; } @@ -1391,6 +1390,7 @@ static int queues_show(int fd, int argc, char **argv) ast_mutex_unlock(&q->lock); q = q->next; } + ast_mutex_unlock(&qlock); return RESULT_SUCCESS; } @@ -1413,6 +1413,7 @@ static int manager_queues_status( struct mansession *s, struct message *m ) struct queue_ent *qe; astman_send_ack(s, m, "Queue status will follow"); time(&now); + ast_mutex_lock(&qlock); q = queues; if (id && &id) { snprintf(idText,256,"ActionID: %s\r\n",id); @@ -1445,6 +1446,7 @@ static int manager_queues_status( struct mansession *s, struct message *m ) ast_mutex_unlock(&q->lock); q = q->next; } + ast_mutex_unlock(&qlock); return RESULT_SUCCESS; } |