GR-303 conferencing fixes
authorMark Spencer <markster@digium.com>
Mon, 13 Dec 2004 15:11:36 +0000 (15:11 +0000)
committerMark Spencer <markster@digium.com>
Mon, 13 Dec 2004 15:11:36 +0000 (15:11 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4441 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_zap.c

index d2cd77d..25b99a3 100755 (executable)
@@ -1158,6 +1158,7 @@ static int reset_conf(struct zt_pvt *p)
        ZT_CONFINFO zi;
        memset(&zi, 0, sizeof(zi));
        p->confno = -1;
+       memset(&p->subs[SUB_REAL].curconf, 0, sizeof(p->subs[SUB_REAL].curconf));
        if (p->subs[SUB_REAL].zfd > -1) {
                if (ioctl(p->subs[SUB_REAL].zfd, ZT_SETCONF, &zi))
                        ast_log(LOG_WARNING, "Failed to reset conferencing on channel %d!\n", p->channel);
@@ -1896,7 +1897,7 @@ int pri_is_up(struct zt_pri *pri)
 int pri_assign_bearer(struct zt_pvt *crv, struct zt_pri *pri, struct zt_pvt *bearer)
 {
        bearer->owner = &inuse;
-       bearer->master = crv;
+       bearer->realcall = crv;
        crv->subs[SUB_REAL].zfd = bearer->subs[SUB_REAL].zfd;
        if (crv->subs[SUB_REAL].owner)
                crv->subs[SUB_REAL].owner->fds[0] = crv->subs[SUB_REAL].zfd;
@@ -2229,6 +2230,7 @@ static int zt_hangup(struct ast_channel *ast)
                        update_conf(p->bearer);
                        reset_conf(p->bearer);
                        p->bearer->owner = NULL;
+                       p->bearer->realcall = NULL;
                        p->bearer = NULL;
                        p->subs[SUB_REAL].zfd = -1;
                        p->pri = NULL;
@@ -7560,8 +7562,8 @@ static void *pri_dchannel(void *vpri)
                                                                } else
                                                                        ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n");
                                                        }
-                                                       if (p->master) {
-                                                               pri_hangup_all(p->master, pri);
+                                                       if (p->realcall) {
+                                                               pri_hangup_all(p->realcall, pri);
                                                        } else if (p->owner)
                                                                p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                        p->inalarm = 1;
@@ -7585,8 +7587,8 @@ static void *pri_dchannel(void *vpri)
                                                        pri->pvts[chanpos]->call = NULL;
                                                }
                                                /* Force soft hangup if appropriate */
-                                               if (pri->pvts[chanpos]->master) 
-                                                       pri_hangup_all(pri->pvts[chanpos]->master, pri);
+                                               if (pri->pvts[chanpos]->realcall) 
+                                                       pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
                                                else if (pri->pvts[chanpos]->owner)
                                                        pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -7601,8 +7603,8 @@ static void *pri_dchannel(void *vpri)
                                                                pri_destroycall(pri->pri, pri->pvts[x]->call);
                                                                pri->pvts[x]->call = NULL;
                                                        }
-                                                       if (pri->pvts[chanpos]->master) 
-                                                               pri_hangup_all(pri->pvts[chanpos]->master, pri);
+                                                       if (pri->pvts[chanpos]->realcall) 
+                                                               pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
                                                        else if (pri->pvts[x]->owner)
                                                                pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                        ast_mutex_unlock(&pri->pvts[x]->lock);
@@ -7656,8 +7658,8 @@ static void *pri_dchannel(void *vpri)
                                                } else {
                                                        ast_log(LOG_WARNING, "Ring requested on channel %d/%d already in use on span %d.  Hanging up owner.\n", 
                                                        PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
-                                                       if (pri->pvts[chanpos]->master) 
-                                                               pri_hangup_all(pri->pvts[chanpos]->master, pri);
+                                                       if (pri->pvts[chanpos]->realcall) 
+                                                               pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
                                                        else
                                                                pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                        ast_mutex_unlock(&pri->pvts[chanpos]->lock);
@@ -7922,7 +7924,7 @@ static void *pri_dchannel(void *vpri)
                                                chanpos = -1;
                                        } else {
                                                ast_mutex_lock(&pri->pvts[chanpos]->lock);
-                                               if (pri->pvts[chanpos]->master && (pri->pvts[chanpos]->master->sig == SIG_FXSKS)) {
+                                               if (pri->pvts[chanpos]->realcall && (pri->pvts[chanpos]->realcall->sig == SIG_FXSKS)) {
                                                        ast_log(LOG_DEBUG, "Starting up GR-303 trunk now that we got CONNECT...\n");
                                                        x = ZT_START;
                                                        res = ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_HOOK, &x);
@@ -7966,8 +7968,8 @@ static void *pri_dchannel(void *vpri)
                                                if (!pri->pvts[chanpos]->alreadyhungup) {
                                                        /* we're calling here zt_hangup so once we get there we need to clear p->call after calling pri_hangup */
                                                        pri->pvts[chanpos]->alreadyhungup = 1;
-                                                       if (pri->pvts[chanpos]->master) 
-                                                               pri_hangup_all(pri->pvts[chanpos]->master, pri);
+                                                       if (pri->pvts[chanpos]->realcall) 
+                                                               pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
                                                        else if (pri->pvts[chanpos]->owner) {
                                                                /* Queue a BUSY instead of a hangup if our cause is appropriate */
                                                                pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
@@ -8022,8 +8024,8 @@ static void *pri_dchannel(void *vpri)
                                        chanpos = pri_fixup_principle(pri, chanpos, e->hangup.call);
                                        if (chanpos > -1) {
                                                ast_mutex_lock(&pri->pvts[chanpos]->lock);
-                                               if (pri->pvts[chanpos]->master) 
-                                                       pri_hangup_all(pri->pvts[chanpos]->master, pri);
+                                               if (pri->pvts[chanpos]->realcall) 
+                                                       pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
                                                else if (pri->pvts[chanpos]->owner) {
                                                        pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
                                                        switch(e->hangup.cause) {
@@ -8096,8 +8098,8 @@ static void *pri_dchannel(void *vpri)
                                                        ast_mutex_lock(&pri->pvts[chanpos]->lock);
                                                        ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan, 
                                                                        pri->pvts[chanpos]->prioffset, pri->span);
-                                                       if (pri->pvts[chanpos]->master) 
-                                                               pri_hangup_all(pri->pvts[chanpos]->master, pri);
+                                                       if (pri->pvts[chanpos]->realcall) 
+                                                               pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
                                                        else if (pri->pvts[chanpos]->owner) {
                                                                ast_log(LOG_WARNING, "Got restart ack on channel %d/%d with owner on span %d\n", pri->pvts[chanpos]->logicalspan, 
                                                                        pri->pvts[chanpos]->prioffset, pri->span);
@@ -8122,8 +8124,8 @@ static void *pri_dchannel(void *vpri)
                                if (chanpos > -1) {
                                        if (pri->pvts[chanpos]) {
                                                ast_mutex_lock(&pri->pvts[chanpos]->lock);
-                                               if (pri->pvts[chanpos]->master) 
-                                                       pri_hangup_all(pri->pvts[chanpos]->master, pri);
+                                               if (pri->pvts[chanpos]->realcall) 
+                                                       pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
                                                else if (pri->pvts[chanpos]->owner) {
                                                        ast_log(LOG_WARNING, "Got restart ack on channel %d/%d span %d with owner\n",
                                                                PRI_SPAN(e->restartack.channel), PRI_CHANNEL(e->restartack.channel), pri->span);