Fix local buglet

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1278 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer 2003-08-08 18:09:24 +00:00
parent d21648495a
commit 5a0a0ff8dd
1 changed files with 11 additions and 11 deletions

View File

@ -69,14 +69,12 @@ static struct local_pvt {
struct local_pvt *next; /* Next entity */ struct local_pvt *next; /* Next entity */
} *locals = NULL; } *locals = NULL;
static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f) static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)
{ {
struct ast_channel *other, *us; struct ast_channel *other;
if (isoutbound) { if (isoutbound) {
us = p->chan;
other = p->owner; other = p->owner;
} else { } else {
us = p->owner;
other = p->chan; other = p->chan;
} }
if (!other) if (!other)
@ -93,10 +91,12 @@ retrylock:
if (pthread_mutex_trylock(&other->lock)) { if (pthread_mutex_trylock(&other->lock)) {
/* Failed to lock. Release main lock and try again */ /* Failed to lock. Release main lock and try again */
ast_pthread_mutex_unlock(&p->lock); ast_pthread_mutex_unlock(&p->lock);
if (us)
ast_pthread_mutex_unlock(&us->lock); ast_pthread_mutex_unlock(&us->lock);
/* Wait just a bit */ /* Wait just a bit */
usleep(1); usleep(1);
/* Only we can destroy ourselves, so we can't disappear here */ /* Only we can destroy ourselves, so we can't disappear here */
if (us)
ast_pthread_mutex_lock(&us->lock); ast_pthread_mutex_lock(&us->lock);
ast_pthread_mutex_lock(&p->lock); ast_pthread_mutex_lock(&p->lock);
goto retrylock; goto retrylock;
@ -116,7 +116,7 @@ static int local_answer(struct ast_channel *ast)
if (isoutbound) { if (isoutbound) {
/* Pass along answer since somebody answered us */ /* Pass along answer since somebody answered us */
struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER }; struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
res = local_queue_frame(p, isoutbound, &answer); res = local_queue_frame(p, isoutbound, &answer, ast);
} else } else
ast_log(LOG_WARNING, "Huh? Local is being asked to answer?\n"); ast_log(LOG_WARNING, "Huh? Local is being asked to answer?\n");
ast_pthread_mutex_unlock(&p->lock); ast_pthread_mutex_unlock(&p->lock);
@ -153,7 +153,7 @@ static int local_write(struct ast_channel *ast, struct ast_frame *f)
/* Just queue for delivery to the other side */ /* Just queue for delivery to the other side */
ast_pthread_mutex_lock(&p->lock); ast_pthread_mutex_lock(&p->lock);
res = local_queue_frame(p, isoutbound, f); res = local_queue_frame(p, isoutbound, f, ast);
check_bridge(p, isoutbound); check_bridge(p, isoutbound);
ast_pthread_mutex_unlock(&p->lock); ast_pthread_mutex_unlock(&p->lock);
return res; return res;
@ -185,7 +185,7 @@ static int local_indicate(struct ast_channel *ast, int condition)
/* Queue up a frame representing the indication as a control frame */ /* Queue up a frame representing the indication as a control frame */
ast_pthread_mutex_lock(&p->lock); ast_pthread_mutex_lock(&p->lock);
f.subclass = condition; f.subclass = condition;
res = local_queue_frame(p, isoutbound, &f); res = local_queue_frame(p, isoutbound, &f, ast);
ast_pthread_mutex_unlock(&p->lock); ast_pthread_mutex_unlock(&p->lock);
return res; return res;
} }
@ -198,7 +198,7 @@ static int local_digit(struct ast_channel *ast, char digit)
int isoutbound = IS_OUTBOUND(ast, p); int isoutbound = IS_OUTBOUND(ast, p);
ast_pthread_mutex_lock(&p->lock); ast_pthread_mutex_lock(&p->lock);
f.subclass = digit; f.subclass = digit;
res = local_queue_frame(p, isoutbound, &f); res = local_queue_frame(p, isoutbound, &f, ast);
ast_pthread_mutex_unlock(&p->lock); ast_pthread_mutex_unlock(&p->lock);
return res; return res;
} }
@ -288,7 +288,7 @@ static int local_hangup(struct ast_channel *ast)
/* Need to actually hangup since there is no PBX */ /* Need to actually hangup since there is no PBX */
ochan = p->chan; ochan = p->chan;
else else
local_queue_frame(p, isoutbound, &f); local_queue_frame(p, isoutbound, &f, ast);
ast_pthread_mutex_unlock(&p->lock); ast_pthread_mutex_unlock(&p->lock);
if (ochan) if (ochan)
ast_hangup(ochan); ast_hangup(ochan);