[asterisk-commits] moy: branch moy/dahdi-tap-1.6.2 r300081 - /team/moy/dahdi-tap-1.6.2/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 31 17:53:12 UTC 2010


Author: moy
Date: Fri Dec 31 11:53:09 2010
New Revision: 300081

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=300081
Log:
improved passive call allocation and debugging

Modified:
    team/moy/dahdi-tap-1.6.2/channels/chan_dahdi.c

Modified: team/moy/dahdi-tap-1.6.2/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/moy/dahdi-tap-1.6.2/channels/chan_dahdi.c?view=diff&rev=300081&r1=300080&r2=300081
==============================================================================
--- team/moy/dahdi-tap-1.6.2/channels/chan_dahdi.c (original)
+++ team/moy/dahdi-tap-1.6.2/channels/chan_dahdi.c Fri Dec 31 11:53:09 2010
@@ -512,6 +512,7 @@
 	char callingname[AST_MAX_EXTENSION];
 	char callednum[AST_MAX_EXTENSION];
 	int proceeding:1;
+	int inuse:1;
 };
 
 struct dahdi_pri {
@@ -565,6 +566,7 @@
 	/*! \brief Whether this is a passive PRI (just sniffing/monitoring) */
 	int passive;
 	/* TODO: allocate this structures on demand only when the pri is flagged as passive */
+	ast_mutex_t pcalls_lock;					/*!< Mutex */
 	struct dahdi_pcall pcalls[MAX_CHANNELS];		        /*!< Passive calls if any.*/
 	struct dahdi_pri *passivepeer;                                  /*!< Peer PRI structure in passive mode */
 	struct dahdi_pvt *pvts[MAX_CHANNELS];				/*!< Member channel pvt structs */
@@ -4383,14 +4385,6 @@
 		p->channel, idx, p->subs[SUB_REAL].dfd, p->subs[SUB_CALLWAIT].dfd, p->subs[SUB_THREEWAY].dfd);
 	p->ignoredtmf = 0;
 
-#ifdef HAVE_PRI
-	if (p->passivepeer) {
-		p->passivepeer->passivepeer = NULL;
-		p->passivepeer->owner = NULL;
-		p->passivepeer = NULL;
-	}
-#endif
-
 	if (idx > -1) {
 		/* Real channel, do some fixup */
 		p->subs[idx].owner = NULL;
@@ -4632,6 +4626,13 @@
 					ast_debug(1, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
 				p->call = NULL;
 				res = 0;
+			}
+			if (p->passivepeer) {
+				p->passivepeer->passivepeer = NULL;
+				p->passivepeer->owner = NULL;
+				p->passivepeer->call = NULL;
+				p->passivepeer = NULL;
+				p->call = NULL;
 			}
 		}
 #endif
@@ -12410,17 +12411,6 @@
 #endif	/* defined(HAVE_PRI) */
 
 #if defined(HAVE_PRI)
-/* Not thread-safe, we assume nobody else is looking for a passive call slot at the same time in this pri */
-static struct dahdi_pcall *dahdi_pri_get_pcall(struct dahdi_pri *pri, void *callref)
-{
-	int i;
-	for (i = 0; i < ARRAY_LEN(pri->pcalls); i++) {
-		if (callref == pri->pcalls[i].callref) {
-			return &pri->pcalls[i];
-		}
-	}
-	return NULL;
-}
 
 int dahdi_pri_get_crv(struct pri *ctrl, q931_call *call);
 int dahdi_pri_get_crv(struct pri *ctrl, q931_call *call)
@@ -12432,29 +12422,96 @@
 	return crv;
 }
 
+static struct dahdi_pcall *dahdi_pri_get_pcall(struct dahdi_pri *pri, void *callref)
+{
+	int i;
+	int crv;
+
+	ast_mutex_lock(&pri->pcalls_lock);
+
+	for (i = 0; i < ARRAY_LEN(pri->pcalls); i++) {
+		if (pri->pcalls[i].callref && !pri->pcalls[i].inuse) {
+			crv = dahdi_pri_get_crv(pri->pri, pri->pcalls[i].callref);
+			/* garbage collection */
+			ast_log(LOG_DEBUG, "Garbage collecting callref %d/%p from span %d in slot %d\n", 
+					crv, pri->pcalls[i].callref, pri->span, i);
+			pri_passive_destroycall(pri->pri, pri->pcalls[i].callref);
+			memset(&pri->pcalls[i], 0, sizeof(pri->pcalls[0]));
+		}
+		if (callref == pri->pcalls[i].callref) {
+			pri->pcalls[i].inuse = 1;
+
+			ast_mutex_unlock(&pri->pcalls_lock);
+
+			return &pri->pcalls[i];
+		}
+	}
+
+	ast_mutex_unlock(&pri->pcalls_lock);
+
+	return NULL;
+}
+
 static struct dahdi_pcall *dahdi_pri_get_pcall_bycrv(struct dahdi_pri *pri, int crv)
 {
 	int i;
 	int tstcrv;
+
+	ast_mutex_lock(&pri->pcalls_lock);
+
 	for (i = 0; i < ARRAY_LEN(pri->pcalls); i++) {
 		tstcrv = pri->pcalls[i].callref ? dahdi_pri_get_crv(pri->pri, pri->pcalls[i].callref) : 0;
 		if (pri->pcalls[i].callref && tstcrv == crv) {
+			if (!pri->pcalls[i].inuse) {
+				ast_log(LOG_ERROR, "Found crv %d in slot %d of span %d with call %p but is no longer in use!\n", 
+						crv, i, pri->span, pri->pcalls[i].callref);
+				continue;
+			}
+
+			ast_mutex_unlock(&pri->pcalls_lock);
+
 			return &pri->pcalls[i];
 		}
 	}
+
+	ast_mutex_unlock(&pri->pcalls_lock);
+
 	return NULL;
 }
 
 static void pri_put_pcall(struct dahdi_pri *pri, void *callref)
 {
 	int i;
+	int crv;
+	int tstcrv;
+	if (!callref) {
+		ast_log(LOG_ERROR, "Cannot put pcall for null callref in span %d\n", pri->span);
+		return;
+	}
+
+	ast_mutex_lock(&pri->pcalls_lock);
+
+	crv = dahdi_pri_get_crv(pri->pri, callref);
 	for (i = 0; i < ARRAY_LEN(pri->pcalls); i++) {
-		if (callref == pri->pcalls[i].callref) {
-			memset(&pri->pcalls[i], 0, sizeof(pri->pcalls[0]));
-		}
-	}
-}
-
+		if (!pri->pcalls[i].callref) {
+			continue;
+		}
+		tstcrv = dahdi_pri_get_crv(pri->pri, pri->pcalls[i].callref);
+		if (tstcrv == crv) {
+			ast_log(LOG_DEBUG, "releasing slot %d in span %d used by callref %d/%p\n", i, pri->span, crv, pri->pcalls[i].callref);
+			if (!pri->pcalls[i].inuse) {
+				ast_log(LOG_ERROR, "slot %d in span %d used by callref %d/%p was released already?\n", 
+						i, pri->span, crv, pri->pcalls[i].callref);
+			}
+			pri->pcalls[i].inuse = 0;
+		}
+	}
+
+	ast_mutex_unlock(&pri->pcalls_lock);
+
+}
+
+/* FIXME: should I be using pri_fixup_principle after pri_find_principle? */
 static void handle_pri_passive_event(struct dahdi_pri *pri, pri_event *e)
 {
 	int chanpos, peerpos, law, layer1, transcap, res, fd;
@@ -12462,6 +12519,7 @@
 	int eventcrv = 0;
 	int enableaudio = 1;
 	struct dahdi_pcall *pcall = NULL;
+	struct dahdi_pcall *peerpcall = NULL;
 	struct ast_channel *c = NULL;
 	struct dahdi_pvt *peerpvt = NULL;
 	struct dahdi_pvt *masterpvt = NULL;
@@ -12479,15 +12537,16 @@
 		/* we cannot use any pri->pvts data structure because we still dont know which channel will be used and therefore cant get
 		 * chanpos (ie, flexible channel was requested), thus, we need our own list of call references */
 		crv = dahdi_pri_get_crv(pri->pri, e->ring.call);
-		ast_log(LOG_DEBUG, "Ring on channel %d of span %d with callref %d\n", e->ring.channel, pri->span, crv);
+		ast_log(LOG_DEBUG, "Ring on channel %d:%d:%d with callref %d\n", 
+				pri->span, PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), crv);
 		pcall = dahdi_pri_get_pcall_bycrv(pri, crv);
 		if (pcall) {
-			ast_log(LOG_WARNING, "There is a call with call reference %d already, ignoring duplicated RING msg\n", crv);
+			ast_log(LOG_WARNING, "There is a channel with callref %d already, ignoring duplicated RING msg\n", crv);
 			break;
 		}
 		pcall = dahdi_pri_get_pcall(pri, NULL);
 		if (!pcall) {
-			ast_log(LOG_ERROR, "Failed to get a free PRI passive call slot, this is a bug!\n");
+			ast_log(LOG_ERROR, "Failed to get a free PRI passive call slot for callref %d, this is a bug!\n", crv);
 			break;
 		}
 		pcall->callref = e->ring.call;
@@ -12499,56 +12558,66 @@
 
 	case PRI_EVENT_PROGRESS:
 		crv = dahdi_pri_get_crv(pri->pri, e->proceeding.call);
-		ast_log(LOG_DEBUG, "Progress on channel %d of span %d with call reference %d\n", e->proceeding.channel, pri->span, crv);
+		ast_log(LOG_DEBUG, "Progress on channel %d:%d:%d with callref %d\n", 
+				pri->span, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv);
 		break;
 
 	case PRI_EVENT_PROCEEDING:
 		crv = dahdi_pri_get_crv(pri->pri, e->proceeding.call);
-		ast_log(LOG_DEBUG, "Proceed on channel %d of span %d with call reference %d\n", e->proceeding.channel, pri->span, crv);
+		ast_log(LOG_DEBUG, "Proceed on channel %d:%d:%d with callref %d\n", 
+				pri->span, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), crv);
 		/* at this point we should know the real b chan that will be used and can therefore proceed to setup the ast channels, but
 		 * only if a couple of call tests are passed */
 
 		/* check that we already know about this call in the peer PRI (which was the one receiving the PRI_EVENT_RING event) */
 		if (!(pcall = dahdi_pri_get_pcall_bycrv(peerpri, crv))) {
 			ast_log(LOG_ERROR, 
-				"we got proceeding in channel number %d/%d on span %d for call reference %d "
+				"we got proceeding in channel %d:%d:%d for callref %d "
 				"but we never got PRI_EVENT_RING for that call on peer span %d?\n", 
+				pri->span,
 				PRI_SPAN(e->proceeding.channel), 
 				PRI_CHANNEL(e->proceeding.channel),
-				pri->span, crv, peerpri->span);
+				crv, peerpri->span);
 			break;
 		}
 		if (pcall->proceeding) {
-			ast_log(LOG_DEBUG, "Ignoring duplicated proceeding with call reference value %d\n", crv);
+			ast_log(LOG_DEBUG, "Ignoring duplicated proceeding with callref %d\n", crv);
 			break;
 		}
 		pcall->proceeding = 1;
+		peerpcall = dahdi_pri_get_pcall(pri, NULL);
+		if (!peerpcall) {
+			ast_log(LOG_ERROR, "Failed to get a free peer PRI passive call slot for callref %d in span %d, this is a bug!\n", crv, pri->span);
+			break;
+		}
+		peerpcall->callref = e->proceeding.call;
+
 		/* check that the layer 1 and trans capability are supported */
 		layer1 = pri_get_layer1(peerpri->pri, pcall->callref);
 		transcap = pri_get_transcap(peerpri->pri, pcall->callref);
 
 		if (PRI_LAYER_1_ULAW != layer1 && PRI_LAYER_1_ALAW != layer1) {
-			ast_log(LOG_NOTICE, "Not monitoring call with unsupported layer 1 format %d\n", layer1);
+			ast_log(LOG_NOTICE, "Not monitoring callref %d with unsupported layer 1 format %d\n", crv, layer1);
 			break;
 		}
 		
 		if (transcap != PRI_TRANS_CAP_SPEECH && transcap != PRI_TRANS_CAP_3_1K_AUDIO && transcap != PRI_TRANS_CAP_7K_AUDIO) {
-			ast_log(LOG_NOTICE, "Not monitoring call with unsupported capability %d\n", transcap);
+			ast_log(LOG_NOTICE, "Not monitoring callref %d with unsupported capability %d\n", crv, transcap);
 			break;
 		}
 
 		/* check for valid channels in both the current span and the peer span */
 		chanpos = pri_find_principle(pri, e->proceeding.channel);
 		if (chanpos < 0) {
-			ast_log(LOG_ERROR, "Proceeding requested on odd/unavailable channel number %d/%d on span %d\n",
-				PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), pri->span);
+			ast_log(LOG_ERROR, "Proceeding requested on odd/unavailable channel %d:%d:%d\n",
+				pri->span, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel));
 			break;
 		}
 
 		peerpos = pri_find_principle(peerpri, e->proceeding.channel);
 		if (peerpos < 0) {
-			ast_log(LOG_ERROR, "Proceeding requested on odd/unavailable peer channel number %d/%d on span %d\n",
-				PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), pri->span);
+			ast_log(LOG_ERROR, "Proceeding requested on odd/unavailable peer channel %d:%d:%d\n",
+				pri->span, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel));
 			break;
 		}
 
@@ -12560,18 +12629,35 @@
 		
 		/* sanity check */
 		if (masterpvt->owner) {
-			ast_log(LOG_ERROR, "Master pvt has already an owner when receiving passive call!!\n");
+			ast_log(LOG_ERROR, "Master pvt has already an owner (%s) with callref %d when receiving new call with callref %d!!\n",
+					masterpvt->owner->name, dahdi_pri_get_crv(pri->pri, masterpvt->call), crv);
 			ast_mutex_unlock(&masterpvt->lock);
 			break;
 		}
 
+		if (masterpvt->call) {
+			ast_log(LOG_ERROR, "Master channel %d:%d:%d has callref %d already but no owner, proceeding with callref %d anyways!\n",
+			pri->span, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), 
+			dahdi_pri_get_crv(pri->pri, masterpvt->call), crv);
+			/* proceed, but this is most likely a memory leak */
+		}
+
 		ast_mutex_lock(&peerpvt->lock);
 		if (peerpvt->owner) {
-			ast_log(LOG_ERROR, "Peer pvt has already an owner when receiving passive call!!\n");
+			ast_log(LOG_ERROR, "Peer pvt has already an owner (%s) with callref %d when receiving new call with callref %d!!\n",
+				peerpvt->owner->name, dahdi_pri_get_crv(peerpri->pri, peerpvt->call), crv);
 			ast_mutex_unlock(&masterpvt->lock);
 			ast_mutex_unlock(&peerpvt->lock);
 			break;
 		}
+
+		if (peerpvt->call) {
+			ast_log(LOG_ERROR, "Peer channel %d:%d:%d has callref %d already but no owner, proceeding with callref %d anyways!\n",
+			pri->span, PRI_SPAN(e->proceeding.channel), PRI_CHANNEL(e->proceeding.channel), 
+			dahdi_pri_get_crv(peerpri->pri, peerpvt->call), crv);
+			/* proceed, but this is most likely a memory leak */
+		}
+
 
 		/* save the call reference */
 		masterpvt->call = e->proceeding.call;
@@ -12605,8 +12691,8 @@
 		law = layer1 == PRI_LAYER_1_ULAW ? DAHDI_LAW_MULAW : DAHDI_LAW_ALAW;
 		c = dahdi_new(masterpvt, AST_STATE_RING, 0, SUB_REAL, law, AST_TRANS_CAP_SPEECH);
 		if (!c) {
-			ast_log(LOG_ERROR, "Failed to create channel for call on channel %d/%d on span %d\n",
-				PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel), pri->span);
+			ast_log(LOG_ERROR, "Failed to create channel for callref %d on channel %d:%d:%d\n",
+					crv, pri->span, PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel));
 			ast_mutex_unlock(&peerpvt->lock);
 			ast_mutex_unlock(&masterpvt->lock);
 			break;
@@ -12659,7 +12745,7 @@
 		fd = dahdi_open("/dev/dahdi/pseudo");
 		/* TODO: what about setting DAHDI_POLICY_IMMEDIATE and buf size? DAHDI_SETLINEAR?? */
 		if (fd < 0 || ioctl(fd, DAHDI_SETCONF, &dahdic)) {
-			ast_log(LOG_ERROR, "Unable to create dahdi conference for tapping\n");
+			ast_log(LOG_ERROR, "Unable to create dahdi conference for tapping, callref = %d\n", crv);
 			ast_mutex_unlock(&peerpvt->lock);
 			ast_mutex_unlock(&masterpvt->lock);
 			ast_hangup(c);
@@ -12668,7 +12754,7 @@
 
 		/* set the conference law */
 		if (dahdi_setlaw(fd, law)) {
-			ast_log(LOG_ERROR, "Unable to set law %d for the tapping conference\n", law);
+			ast_log(LOG_ERROR, "Unable to set law %d for the tapping conference, callref = %d\n", law, crv);
 			ast_mutex_unlock(&peerpvt->lock);
 			ast_mutex_unlock(&masterpvt->lock);
 			ast_hangup(c);
@@ -12700,12 +12786,12 @@
 			ast_hangup(c);
 			break;
 		}
-		ast_log(LOG_DEBUG, "Created conference %d with fd %d between dahdi chans %d and %d for ast channel %s\n", 
+		ast_log(LOG_DEBUG, "Created conference %d with fd %d between dahdi chans %d and %d for ast channel %s, callref = %d\n", 
 				masterpvt->passiveconf,
 				masterpvt->passivefd,
 		      		masterpvt->channel,
 		      		peerpvt->channel,
-				c->name);
+				c->name, crv);
 
 		/* from now on, reading from the conference has the mix of both tapped channels, we can now launch the pbx thread */
 		if (ast_pbx_start(c) != AST_PBX_SUCCESS) {
@@ -12717,13 +12803,15 @@
 		break;
 
 	case PRI_EVENT_ANSWER:
-		ast_log(LOG_DEBUG, "Answer on channel %d of span %d\n", e->proceeding.channel, pri->span);
+		crv = dahdi_pri_get_crv(pri->pri, e->answer.call);
+		ast_log(LOG_DEBUG, "Answer on channel %d:%d:%d with callref %d\n", 
+				pri->span, PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), crv);
 
 		/* get the chan pos for the answered channel and check we have an owner already */
 		chanpos = pri_find_principle(pri, e->answer.channel);
 		if (chanpos < 0) {
-			ast_log(LOG_ERROR, "Answer requested on odd/unavailable channel number %d/%d on span %d\n",
-				PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), pri->span);
+			ast_log(LOG_ERROR, "Answer with callref %d requested on odd/unavailable channel %d:%d:%d\n",
+				crv, pri->span, PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel));
 			break;
 		}
 		masterpvt = pri->pvts[chanpos];
@@ -12731,8 +12819,8 @@
 		if (!masterpvt->owner) {
 			ast_mutex_unlock(&masterpvt->lock);
 			/* this may be a valid condition if the user hangup the ast channel before the tapped line is answered */
-			ast_log(LOG_NOTICE, "Ignoring answer in tapped channel number %d/%d on span %d, no owner found\n",
-				PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), pri->span);
+			ast_log(LOG_NOTICE, "Ignoring answer with callref %d in tapped channel %d:%d:%d with no owner\n",
+				crv, pri->span, PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel));
 			break;
 		}
 
@@ -12741,22 +12829,16 @@
 		ast_mutex_unlock(&masterpvt->lock);
 		break;
 
-	case PRI_EVENT_HANGUP:
-
-		ast_log(LOG_DEBUG, "Hangup on channel %d of span %d\n", e->hangup.channel, pri->span);
+	case PRI_EVENT_HANGUP_REQ:
+		crv = dahdi_pri_get_crv(pri->pri, e->hangup.call);
+		ast_log(LOG_DEBUG, "Hangup on channel %d:%d:%d with callref %d\n", 
+				pri->span, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), crv);
 		chanpos = pri_find_principle(pri, e->hangup.channel);
 		if (chanpos < 0) {
-			ast_log(LOG_ERROR, "Hangup requested on odd/unavailable channel number %d/%d on span %d\n",
-				PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
+			ast_log(LOG_ERROR, "Hangup with callref %d requested on odd/unavailable channel %d:%d:%d\n",
+				crv, pri->span, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel));
 			break;
 		}
-		/* first put back the passive call slot, if any was used, since 
-		 * regardless of whethere there is owner or not, this resource must be freed 
-		 * we dont know if the same side with the callref will hangup, so we need to try to put the call
-		 * back in both pri and peerpri
-		 */
-		pri_put_pcall(pri, e->hangup.call);
-		pri_put_pcall(peerpri, e->hangup.call);
 
 		/* now try to hangup if needed */
 		masterpvt = pri->pvts[chanpos];
@@ -12775,22 +12857,23 @@
 		crv = dahdi_pri_get_crv(pri->pri, masterpvt->call);
 		eventcrv = dahdi_pri_get_crv(pri->pri, e->hangup.call);
 		if (crv != eventcrv) {
+			ast_log(LOG_ERROR, "Ignoring hangup in tapped channel %s %d:%d:%d, our call %d != hangup call %d\n",
+				masterpvt->owner->name, pri->span, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), crv, eventcrv);
 			ast_channel_unlock(masterpvt->owner);
 			ast_mutex_unlock(&masterpvt->lock);
-			/* this may be a valid condition if the user hangup the ast channel before the tapped line is terminated */
-			ast_log(LOG_NOTICE, "Ignoring hangup in tapped channel number %d/%d on span %d, our call %d != hangup call %d\n",
-				PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span, crv, eventcrv);
 			break;
 		}
 		ast_queue_hangup(masterpvt->owner);
+		ast_log(LOG_DEBUG, "Enqueued hangup on channel %s (%d:%d:%d) with callref %d\n", 
+				masterpvt->owner->name, pri->span, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), crv);
 		ast_channel_unlock(masterpvt->owner);
 		ast_mutex_unlock(&masterpvt->lock);
 		break;
 
 	case PRI_EVENT_HANGUP_ACK:
-
-		ast_log(LOG_DEBUG, "Hangup ack on channel %d of span %d\n", e->hangup.channel, pri->span);
-		/* put back the passive call slot, if any was used, not sure if this do any good, PRI_EVENT_HANGUP does this */
+		crv = dahdi_pri_get_crv(pri->pri, e->hangup.call);
+		ast_log(LOG_DEBUG, "Hangup ack on channel %d:%d:%d with callref %d (%p)\n", 
+				pri->span, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), crv, e->hangup.call);
 		pri_put_pcall(pri, e->hangup.call);
 		pri_put_pcall(peerpri, e->hangup.call);
 		break;
@@ -12810,6 +12893,11 @@
 
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
 
+	for (i = 0; i < NUM_DCHANS; i++) {
+		if (!pri->dchannels[i])
+			break;
+		pri_set_debug(pri->dchans[i], PRI_DEBUG_Q931_STATE);
+	}
 	for (;;) {
 		for (i = 0; i < NUM_DCHANS; i++) {
 			if (!pri->dchannels[i])
@@ -14895,6 +14983,7 @@
 	memset(pris, 0, sizeof(pris));
 	for (i = 0; i < NUM_SPANS; i++) {
 		ast_mutex_init(&pris[i].lock);
+		ast_mutex_init(&pris[i].pcalls_lock);
 		pris[i].offset = -1;
 		pris[i].master = AST_PTHREADT_NULL;
 		for (j = 0; j < NUM_DCHANS; j++)
@@ -17803,6 +17892,7 @@
 	memset(pris, 0, sizeof(pris));
 	for (y = 0; y < NUM_SPANS; y++) {
 		ast_mutex_init(&pris[y].lock);
+		ast_mutex_init(&pris[y].pcalls_lock);
 		pris[y].offset = -1;
 		pris[y].master = AST_PTHREADT_NULL;
 		for (i = 0; i < NUM_DCHANS; i++)




More information about the asterisk-commits mailing list