--- channel.c 2004-05-18 16:29:27.000000000 -0400 +++ channel.c.merged 2004-05-18 16:44:16.000000000 -0400 @@ -276,20 +276,21 @@ struct varshead *headp; /* If shutting down, don't allocate any new channels */ if (shutting_down) return NULL; ast_mutex_lock(&chlock); tmp = malloc(sizeof(struct ast_channel)); if (tmp) { memset(tmp, 0, sizeof(struct ast_channel)); + tmp->used_by_dual_xfer=0; pvt = malloc(sizeof(struct ast_channel_pvt)); if (pvt) { memset(pvt, 0, sizeof(struct ast_channel_pvt)); tmp->sched = sched_context_create(); if (tmp->sched) { for (x=0;xfds[x] = -1; #ifdef ZAPTEL_OPTIMIZATIONS tmp->timingfd = open("/dev/zap/timer", O_RDWR); if (tmp->timingfd > -1) { @@ -621,21 +622,28 @@ clone->pvt->readtrans = NULL; clone->pvt->rawwriteformat = clone->nativeformats; clone->pvt->rawreadformat = clone->nativeformats; } int ast_hangup(struct ast_channel *chan) { int res = 0; /* Don't actually hang up a channel that will masquerade as someone else, or if someone is going to masquerade as us */ + ast_mutex_lock(&chan->lock); + + if (chan->used_by_dual_xfer==1) { + ast_mutex_unlock(&chan->lock); + return 0; + } + if (chan->masq) { if (ast_do_masquerade(chan)) ast_log(LOG_WARNING, "Failed to perform masquerade\n"); } if (chan->masq) { ast_log(LOG_WARNING, "%s getting hung up, but someone is trying to masq into us?!?\n", chan->name); ast_mutex_unlock(&chan->lock); return 0; }