dect
/
asterisk
Archived
13
0
Fork 0

Trustingly add Thorston's deadlock patch

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1708 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
markster 2003-11-08 04:35:57 +00:00
parent 578e6fddfe
commit 5a55a162d7
3 changed files with 18 additions and 9 deletions

View File

@ -47,6 +47,9 @@ Tilghman Lesher - Route lookup code, gotoiftime application, and various
other patches. http://asterisk.drunkcoder.com/ other patches. http://asterisk.drunkcoder.com/
Jayson Vantuyl - Manager protocol changes, various other bugs. Jayson Vantuyl - Manager protocol changes, various other bugs.
jvantuyl@computingedge.net jvantuyl@computingedge.net
Thorsten Lockert - OpenBSD, FreeBSD ports, making MacOS X port run on 10.3,
dialplan include verification, route lookup on OpenBSD, various other
bugs. tholo@sigmasoft.com
=== OTHER CONTRIBUTIONS === === OTHER CONTRIBUTIONS ===
John Todd - Monkey sounds and associated teletorture prompt John Todd - Monkey sounds and associated teletorture prompt

View File

@ -609,10 +609,8 @@ static int wait_our_turn(struct queue_ent *qe)
struct queue_ent *ch; struct queue_ent *ch;
int res = 0; int res = 0;
for (;;) { for (;;) {
/* Atomically read the parent head */ /* Atomically read the parent head -- does not need a lock */
ast_mutex_lock(&qe->parent->lock);
ch = qe->parent->head; ch = qe->parent->head;
ast_mutex_unlock(&qe->parent->lock);
/* If we are now at the top of the head, break out */ /* If we are now at the top of the head, break out */
if (qe->parent->head == qe) if (qe->parent->head == qe)
break; break;
@ -722,6 +720,7 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
/* Get a technology/[device:]number pair */ /* Get a technology/[device:]number pair */
tmp = malloc(sizeof(struct localuser)); tmp = malloc(sizeof(struct localuser));
if (!tmp) { if (!tmp) {
ast_mutex_unlock(&qe->parent->lock);
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
goto out; goto out;
} }
@ -859,11 +858,8 @@ out:
static int wait_a_bit(struct queue_ent *qe) static int wait_a_bit(struct queue_ent *qe)
{ {
int retrywait; /* Don't need to hold the lock while we setup the outgoing calls */
/* Hold the lock while we setup the outgoing calls */ int retrywait = qe->parent->retry * 1000;
ast_mutex_lock(&qe->parent->lock);
retrywait = qe->parent->retry * 1000;
ast_mutex_unlock(&qe->parent->lock);
return ast_waitfordigit(qe->chan, retrywait); return ast_waitfordigit(qe->chan, retrywait);
} }
@ -1203,6 +1199,7 @@ static void reload_queues(void)
/* Mark all queues as dead for the moment */ /* Mark all queues as dead for the moment */
q = queues; q = queues;
while(q) { while(q) {
q->dead = 1;
q = q->next; q = q->next;
} }
/* Chug through config file */ /* Chug through config file */
@ -1349,8 +1346,10 @@ static int queues_show(int fd, int argc, char **argv)
time(&now); time(&now);
if (argc != 2) if (argc != 2)
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
ast_mutex_lock(&qlock);
q = queues; q = queues;
if (!q) { if (!q) {
ast_mutex_unlock(&qlock);
ast_cli(fd, "No queues.\n"); ast_cli(fd, "No queues.\n");
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -1391,6 +1390,7 @@ static int queues_show(int fd, int argc, char **argv)
ast_mutex_unlock(&q->lock); ast_mutex_unlock(&q->lock);
q = q->next; q = q->next;
} }
ast_mutex_unlock(&qlock);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -1413,6 +1413,7 @@ static int manager_queues_status( struct mansession *s, struct message *m )
struct queue_ent *qe; struct queue_ent *qe;
astman_send_ack(s, m, "Queue status will follow"); astman_send_ack(s, m, "Queue status will follow");
time(&now); time(&now);
ast_mutex_lock(&qlock);
q = queues; q = queues;
if (id && &id) { if (id && &id) {
snprintf(idText,256,"ActionID: %s\r\n",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); ast_mutex_unlock(&q->lock);
q = q->next; q = q->next;
} }
ast_mutex_unlock(&qlock);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }

View File

@ -1154,10 +1154,14 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
if( options ) if( options )
if( strchr( options, 's' ) ) if( strchr( options, 's' ) )
play_announcement = 0; play_announcement = 0;
ast_mutex_unlock(&p->lock);
ast_mutex_unlock(&agentlock);
if( !res && play_announcement ) if( !res && play_announcement )
res = ast_streamfile(chan, filename, chan->language); res = ast_streamfile(chan, filename, chan->language);
if (!res) if (!res)
ast_waitstream(chan, ""); ast_waitstream(chan, "");
ast_mutex_lock(&agentlock);
ast_mutex_lock(&p->lock);
if (!res) { if (!res) {
res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats)); res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats));
if (res) if (res)
@ -1173,6 +1177,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
res = -1; res = -1;
if (callbackmode && !res) { if (callbackmode && !res) {
/* Just say goodbye and be done with it */ /* Just say goodbye and be done with it */
ast_mutex_unlock(&agentlock);
if (!res) if (!res)
res = ast_safe_sleep(chan, 500); res = ast_safe_sleep(chan, 500);
res = ast_streamfile(chan, "vm-goodbye", chan->language); res = ast_streamfile(chan, "vm-goodbye", chan->language);
@ -1181,7 +1186,6 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
if (!res) if (!res)
res = ast_safe_sleep(chan, 1000); res = ast_safe_sleep(chan, 1000);
ast_mutex_unlock(&p->lock); ast_mutex_unlock(&p->lock);
ast_mutex_unlock(&agentlock);
} else if (!res) { } else if (!res) {
#ifdef HONOR_MUSIC_CLASS #ifdef HONOR_MUSIC_CLASS
/* check if the moh class was changed with setmusiconhold */ /* check if the moh class was changed with setmusiconhold */