[libpri-commits] rmudgett: branch 1.4 r1912 - in /branches/1.4: pri.c q931.c

SVN commits to the libpri project libpri-commits at lists.digium.com
Fri Aug 27 18:37:50 CDT 2010


Author: rmudgett
Date: Fri Aug 27 18:37:46 2010
New Revision: 1912

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1912
Log:
Convert most references of Q931_MAX_TEI to use ARRAY_LEN().

* Minor comment correction in q931_destroycall().
* Redundant logic removal q931_destroycall().
"W && X && (Y || W && Z)" is the same as "W && X && (Y || Z)"

Modified:
    branches/1.4/pri.c
    branches/1.4/q931.c

Modified: branches/1.4/pri.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri.c?view=diff&rev=1912&r1=1911&r2=1912
==============================================================================
--- branches/1.4/pri.c (original)
+++ branches/1.4/pri.c Fri Aug 27 18:37:46 2010
@@ -832,7 +832,7 @@
 
 	/* Update all subcalls with new local_id. */
 	if (call->outboundbroadcast && call->master_call == call) {
-		for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
+		for (idx = 0; idx < ARRAY_LEN(call->subcalls); ++idx) {
 			subcall = call->subcalls[idx];
 			if (subcall) {
 				subcall->local_id = party_id;
@@ -899,7 +899,7 @@
 	 * but update it just in case.
 	 */
 	if (call->outboundbroadcast && call->master_call == call) {
-		for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
+		for (idx = 0; idx < ARRAY_LEN(call->subcalls); ++idx) {
 			subcall = call->subcalls[idx];
 			if (subcall) {
 				subcall->redirecting.to = call->redirecting.to;

Modified: branches/1.4/q931.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q931.c?view=diff&rev=1912&r1=1911&r2=1912
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Fri Aug 27 18:37:46 2010
@@ -3956,7 +3956,7 @@
 		if (cur == c) {
 			slaveidx = -1;
 			if (slave) {
-				for (i = 0; i < Q931_MAX_TEI; i++) {
+				for (i = 0; i < ARRAY_LEN(cur->subcalls); ++i) {
 					if (cur->subcalls[i] == slave) {
 						if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
 							pri_message(ctrl, "Destroying subcall %p of call %p at %d\n",
@@ -3971,7 +3971,7 @@
 			}
 
 			slavesleft = 0;
-			for (i = 0; i < Q931_MAX_TEI; i++) {
+			for (i = 0; i < ARRAY_LEN(cur->subcalls); ++i) {
 				if (cur->subcalls[i]) {
 					if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
 						pri_message(ctrl, "Subcall still present at %d\n", i);
@@ -3981,8 +3981,8 @@
 			}
 
 			/* We have 3 different phases to deal with:
-			 * 1.) Sent outbound call, but no response, indicated by t203 present
-			 * 2.) Sent outbound call, with responses, indicated by lack of t203 and subcalls present
+			 * 1.) Sent outbound call, but no response (no subcalls present)
+			 * 2.) Sent outbound call, with responses (subcalls present)
 			 * 3.) Outbound call connected, indicated by pri_winner > -1
 			 *
 			 * If chan_dahdi hangs up in phase:
@@ -4005,7 +4005,7 @@
 			 *  If, when the library user hangs up the master call, and there are more than one subcall up, we fake clear
 			 *  regardless of whether or not we drop down to one subcall left in the clearing process.
 			 *
-			 *  If there are only one call up, we mirror what it does.
+			 *  If there is only one call up, we mirror what it does.
 			 *
 			 *  OR
 			 *
@@ -4023,8 +4023,8 @@
 			 *  call as dead and free it when the last subcall clears.
 			 */
 
-			if ((slave && !slavesleft) &&
-				((cur->pri_winner < 0) || (slave && slaveidx != cur->pri_winner))) {
+			if (slave && !slavesleft /* i.e., The last slave was just destroyed */
+				&& (cur->pri_winner < 0 || slaveidx != cur->pri_winner)) {
 				pri_create_fake_clearing(cur, ctrl);
 				return;
 			}
@@ -4606,7 +4606,7 @@
 
 	if (call->outboundbroadcast && call->master_call == call) {
 		status = 0;
-		for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
+		for (idx = 0; idx < ARRAY_LEN(call->subcalls); ++idx) {
 			subcall = call->subcalls[idx];
 			if (subcall) {
 				/* Send to all subcalls that have given a positive response. */
@@ -5996,7 +5996,7 @@
 			int slaves = 0;
 
 			/* Master is called with hangup - initiate hangup with slaves */
-			for (i = 0; i < Q931_MAX_TEI; i++) {
+			for (i = 0; i < ARRAY_LEN(call->subcalls); ++i) {
 				if (call->subcalls[i]) {
 					slaves++;
 					if (i == call->master_call->pri_winner) {
@@ -6248,7 +6248,7 @@
 	int i;
 
 	call = call->master_call;
-	for (i = 0; i < Q931_MAX_TEI; i++) {
+	for (i = 0; i < ARRAY_LEN(call->subcalls); ++i) {
 		if (call->subcalls[i])
 			count++;
 	}
@@ -6263,7 +6263,7 @@
 	int i;
 
 	/* Set the winner first */
-	for (i = 0; i < Q931_MAX_TEI; i++) {
+	for (i = 0; i < ARRAY_LEN(realcall->subcalls); ++i) {
 		if (realcall->subcalls[i] && realcall->subcalls[i] == subcall) {
 			realcall->pri_winner = i;
 		}
@@ -6274,7 +6274,7 @@
 	}
 
 	/* Start tear down of calls that were not chosen */
-	for (i = 0; i < Q931_MAX_TEI; i++) {
+	for (i = 0; i < ARRAY_LEN(realcall->subcalls); ++i) {
 		if (realcall->subcalls[i] && realcall->subcalls[i] != subcall) {
 			initiate_hangup_if_needed(realcall->subcalls[i]->pri, realcall->subcalls[i],
 				PRI_CAUSE_NONSELECTED_USER_CLEARING);
@@ -6289,7 +6289,7 @@
 	int firstfree = -1;
 
 	/* First try to locate our subcall */
-	for (i = 0; i < Q931_MAX_TEI; i++) {
+	for (i = 0; i < ARRAY_LEN(master_call->subcalls); ++i) {
 		if (master_call->subcalls[i]) {
 			if (master_call->subcalls[i]->pri == ctrl) {
 				return master_call->subcalls[i];
@@ -6300,7 +6300,7 @@
 	}
 	if (firstfree < 0) {
 		pri_error(ctrl, "Tried to add more than %d TEIs to call and failed\n",
-			Q931_MAX_TEI);
+			(int) ARRAY_LEN(master_call->subcalls));
 		return NULL;
 	}
 
@@ -6316,7 +6316,7 @@
 	cur->apdus = NULL;
 	cur->bridged_call = NULL;
 	//cur->master_call = master_call; /* We get this assignment for free. */
-	for (i = 0; i < Q931_MAX_TEI; ++i) {
+	for (i = 0; i < ARRAY_LEN(cur->subcalls); ++i) {
 		cur->subcalls[i] = NULL;
 	}
 	cur->t303_timer = 0;/* T303 should only be on on the master call */




More information about the libpri-commits mailing list