summaryrefslogtreecommitdiff
path: root/channels/chan_local.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-08-19 19:36:52 +0000
committerMark Spencer <markster@digium.com>2003-08-19 19:36:52 +0000
commit52095246a6019eb96e80e2ddf04dda3cbfa0b9d0 (patch)
treeb9e2020e064b7443f8dea32bad20a129427c66ac /channels/chan_local.c
parente492a6ef882b2e07fb1fd268f33d08d2d1457891 (diff)
Fix race for fast hanguyp
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1377 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_local.c')
-rwxr-xr-xchannels/chan_local.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 1cafbebcc..533ed8e77 100755
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -64,6 +64,7 @@ static struct local_pvt {
int glaredetect; /* Detect glare on hangup */
int cancelqueue; /* Cancel queue */
int alreadymasqed; /* Already masqueraded */
+ int launchedpbx; /* Did we launch the PBX */
struct ast_channel *owner; /* Master Channel */
struct ast_channel *chan; /* Outbound channel */
struct local_pvt *next; /* Next entity */
@@ -226,7 +227,9 @@ static int local_digit(struct ast_channel *ast, char digit)
static int local_call(struct ast_channel *ast, char *dest, int timeout)
{
struct local_pvt *p = ast->pvt->pvt;
-
+ int res;
+
+ ast_mutex_lock(&p->lock);
if (p->owner->callerid)
p->chan->callerid = strdup(p->owner->callerid);
else
@@ -235,8 +238,11 @@ static int local_call(struct ast_channel *ast, char *dest, int timeout)
p->chan->ani = strdup(p->owner->ani);
else
p->chan->ani = NULL;
+ p->launchedpbx = 1;
/* Start switch on sub channel */
- return ast_pbx_start(p->chan);
+ res = ast_pbx_start(p->chan);
+ ast_mutex_unlock(&p->lock);
+ return res;
}
static void local_destroy(struct local_pvt *p)
@@ -270,9 +276,10 @@ static int local_hangup(struct ast_channel *ast)
struct ast_channel *ochan = NULL;
int glaredetect;
ast_mutex_lock(&p->lock);
- if (isoutbound)
+ if (isoutbound) {
p->chan = NULL;
- else
+ p->launchedpbx = 0;
+ } else
p->owner = NULL;
ast->pvt->pvt = NULL;
@@ -304,7 +311,7 @@ static int local_hangup(struct ast_channel *ast)
free(p);
return 0;
}
- if (p->chan && !p->chan->pbx)
+ if (p->chan && !p->launchedpbx)
/* Need to actually hangup since there is no PBX */
ochan = p->chan;
else
@@ -364,7 +371,7 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
if (tmp) {
tmp->nativeformats = p->reqformat;
tmp2->nativeformats = p->reqformat;
- snprintf(tmp->name, sizeof(tmp->name), "Local/%s@%s-%04x.1", p->exten, p->context, randnum);
+ snprintf(tmp->name, sizeof(tmp->name), "Local/%s@%s-%04x,1", p->exten, p->context, randnum);
snprintf(tmp2->name, sizeof(tmp2->name), "Local/%s@%s-%04x,2", p->exten, p->context, randnum);
tmp->type = type;
tmp2->type = type;