[libpri-commits] rmudgett: branch rmudgett/ntptmp r1130 - /team/rmudgett/ntptmp/q931.c

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue Sep 22 15:53:02 CDT 2009


Author: rmudgett
Date: Tue Sep 22 15:52:59 2009
New Revision: 1130

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1130
Log:
Call record D channel controller pointer changes.

*  Do not change the call->pri pointer on BRI calls in q931_getcall().
*  Restore BRI PTMP TE call->pri pointer behaviour.
*  Destroying a call should clear the call->hold_timer in the master call
only.

Modified:
    team/rmudgett/ntptmp/q931.c

Modified: team/rmudgett/ntptmp/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/ntptmp/q931.c?view=diff&rev=1130&r1=1129&r2=1130
==============================================================================
--- team/rmudgett/ntptmp/q931.c (original)
+++ team/rmudgett/ntptmp/q931.c Tue Sep 22 15:52:59 2009
@@ -3108,8 +3108,10 @@
 			case PRI_SWITCH_GR303_TMC_SWITCHING:
 				break;
 			default:
-				/* PRI is set to whoever called us */
-				cur->pri = ctrl;
+				if (!ctrl->bri) {
+					/* PRI is set to whoever called us */
+					cur->pri = ctrl;
+				}
 				break;
 			}
 			return cur;
@@ -3160,15 +3162,23 @@
 	q931_party_id_init(&cur->remote_id);
 	q931_party_redirecting_init(&cur->redirecting);
 
+	/* PRI is set to whoever called us */
+	if (BRI_TE_PTMP(ctrl)) {
+		/*
+		 * Point to the master to avoid stale pointer problems if
+		 * the TEI is removed later.
+		 */
+		cur->pri = master;
+	} else {
+		cur->pri = ctrl;
+	}
+
 	/* Append to end of list */
 	if (prev) {
 		prev->next = cur;
 	} else {
 		*master->callpool = cur;
 	}
-
-	/* PRI is set to whoever called us */
-	cur->pri = ctrl;
 
 	return cur;
 }
@@ -3203,7 +3213,6 @@
 {
 	stop_t303(cur);
 	pri_schedule_del(cur->pri, cur->retranstimer);
-	pri_schedule_del(cur->pri, cur->hold_timer);
 	pri_call_apdu_queue_cleanup(cur);
 	free(cur);
 }
@@ -3231,10 +3240,10 @@
 		if ((c && (cur == c)) || (!c && (cur->cr == cr))) {
 			if (slave) {
 				for (i = 0; i < Q931_MAX_TEI; i++) {
-					if (c->subcalls[i] == slave) {
-						pri_error(ctrl, "Destroying subcall %p of call %p at %d\n", slave, c, i);
+					if (cur->subcalls[i] == slave) {
+						pri_error(ctrl, "Destroying subcall %p of call %p at %d\n", slave, cur, i);
 						cleanup_and_free_call(slave);
-						c->subcalls[i] = NULL;
+						cur->subcalls[i] = NULL;
 						slaveidx = i;
 						break;
 					}
@@ -3242,7 +3251,7 @@
 			}
 
 			for (i = 0; i < Q931_MAX_TEI; i++) {
-				if (c->subcalls[i]) {
+				if (cur->subcalls[i]) {
 					pri_error(ctrl, "Subcall still present at %d\n", i);
 					slavesleft++;
 				}
@@ -3292,18 +3301,17 @@
 			 */
 
 			if ((slave && !slavesleft) &&
-				((c->pri_winner < 0) || (slave && slaveidx != c->pri_winner))) {
-				pri_create_fake_clearing(c, ctrl);
+				((cur->pri_winner < 0) || (slave && slaveidx != cur->pri_winner))) {
+				pri_create_fake_clearing(cur, ctrl);
 				return;
 			}
 
-			if (!slavesleft)
-				goto ultimate_destruction;
-
-			return;
-
-ultimate_destruction:
-			if ((c->pri_winner > -1) && c->outboundbroadcast) {
+			if (slavesleft) {
+				return;
+			}
+
+			/* Master call or normal call destruction. */
+			if ((cur->pri_winner > -1) && cur->outboundbroadcast) {
 				pri_error(ctrl, "Since we already had a winner, we should just be able to kill the call anyways\n");
 			}
 			if (prev)
@@ -3315,8 +3323,9 @@
 					"NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s, hold-state %s\n",
 					q931_call_state_str(cur->ourcallstate),
 					q931_call_state_str(cur->peercallstate),
-					q931_hold_state_str(cur->master_call->hold_state));
-			cleanup_and_free_call(c);
+					q931_hold_state_str(cur->hold_state));
+			pri_schedule_del(ctrl, cur->hold_timer);
+			cleanup_and_free_call(cur);
 			return;
 		}
 		prev = cur;
@@ -3586,7 +3595,7 @@
 	len = sizeof(buf) - len;
 
 	ctrl = call->pri;
-	if (q931_is_ptmp(ctrl) && (ctrl->localtype == PRI_CPE)) {
+	if (BRI_TE_PTMP(ctrl)) {
 		/*
 		 * Must use the BRI subchannel structure to send with the correct TEI.
 		 * Note: If the subchannel is NULL then there is no TEI assigned and
@@ -3596,7 +3605,7 @@
 	}
 	if (ctrl) {
 		pri_message(ctrl, "Sending message for call %p on %p TEI/SAPI %d/%d, call->pri is %p, TEI/SAPI %d/%d\n", call, ctrl, ctrl->tei, ctrl->sapi, call->pri, call->pri->tei, call->pri->sapi);
-		q931_xmit(call->pri, h, len, 1, (msgtype == Q931_SETUP) ? 1 : 0);
+		q931_xmit(ctrl, h, len, 1, (msgtype == Q931_SETUP) ? 1 : 0);
 	}
 	call->acked = 1;
 	return 0;




More information about the libpri-commits mailing list