[svn-commits] rmudgett: branch 1.4 r1060 - in /branches/1.4: q921.c q931.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Sep 2 15:04:07 CDT 2009


Author: rmudgett
Date: Wed Sep  2 15:04:03 2009
New Revision: 1060

URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=1060
Log:
Optimized calls to pri_schedule_del().

There is no need to test if a scheduled event is running before calling
pri_schedule_del().

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

Modified: branches/1.4/q921.c
URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/q921.c?view=diff&rev=1060&r1=1059&r2=1060
==============================================================================
--- branches/1.4/q921.c (original)
+++ branches/1.4/q921.c Wed Sep  2 15:04:03 2009
@@ -139,8 +139,7 @@
 #endif
 	pri->ri = random() % 65535;
 	q921_send_tei(pri, Q921_TEI_IDENTITY_REQUEST, pri->ri, Q921_TEI_GROUP, 1);
-	if (pri->t202_timer)
-		pri_schedule_del(pri, pri->t202_timer);
+	pri_schedule_del(pri, pri->t202_timer);
 	pri->t202_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T202], q921_tei_request, pri);
 }
 
@@ -174,8 +173,8 @@
 {
 	struct pri *pri = vpri;
 	q921_h h;
+
 	pri_schedule_del(pri, pri->sabme_timer);
-	pri->sabme_timer = 0;
 	pri->sabme_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], q921_send_sabme_now, pri);
 	if (!now)
 		return;
@@ -253,8 +252,7 @@
 {
 	if (pri->debug & PRI_DEBUG_Q921_DUMP)
 		pri_message(pri, "-- Restarting T200 timer\n");
-	if (pri->t200_timer)
-		pri_schedule_del(pri, pri->t200_timer);
+	pri_schedule_del(pri, pri->t200_timer);
 	pri->t200_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri);
 }
 
@@ -262,8 +260,7 @@
 {
 	if (pri->debug & PRI_DEBUG_Q921_DUMP)
 		pri_message(pri, "-- Restarting T203 timer\n");
-	if (pri->t203_timer) 
-		pri_schedule_del(pri, pri->t203_timer);
+	pri_schedule_del(pri, pri->t203_timer);
 	pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T203], t203_expire, pri);
 }
 
@@ -311,10 +308,8 @@
 		if (pri->debug & PRI_DEBUG_Q921_DUMP)
 			pri_message(pri, "-- Since there was nothing left, stopping T200 counter\n");
 		/* Something was ACK'd.  Stop T200 counter */
-		if (pri->t200_timer) {
-			pri_schedule_del(pri, pri->t200_timer);
-			pri->t200_timer = 0;
-		}
+		pri_schedule_del(pri, pri->t200_timer);
+		pri->t200_timer = 0;
 	}
 	if (pri->t203_timer) {
 		if (pri->debug & PRI_DEBUG_Q921_DUMP)
@@ -785,10 +780,8 @@
 pri_event *q921_dchannel_up(struct pri *pri)
 {
 	/* Stop any SABME retransmissions */
-	if (pri->sabme_timer) {
-		pri_schedule_del(pri, pri->sabme_timer);
-		pri->sabme_timer = 0;
-	}
+	pri_schedule_del(pri, pri->sabme_timer);
+	pri->sabme_timer = 0;
 	
 	/* Reset any rejects */
 	pri->sentrej = 0;
@@ -833,12 +826,9 @@
 	pri->v_na = 0;
 	pri->window = pri->timers[PRI_TIMER_K];
 	pri->windowlen = 0;
-	if (pri->sabme_timer)
-		pri_schedule_del(pri, pri->sabme_timer);
-	if (pri->t203_timer)
-		pri_schedule_del(pri, pri->t203_timer);
-	if (pri->t200_timer)
-		pri_schedule_del(pri, pri->t200_timer);
+	pri_schedule_del(pri, pri->sabme_timer);
+	pri_schedule_del(pri, pri->t203_timer);
+	pri_schedule_del(pri, pri->t200_timer);
 	pri->sabme_timer = 0;
 	pri->sabme_count = 0;
 	pri->t203_timer = 0;
@@ -909,10 +899,8 @@
 			pri_message(pri, "TEI assignment received for invalid Ri %02x (our is %02x)\n", ri, pri->ri);
 			return NULL;
 		}
-		if (pri->t202_timer) {
-			pri_schedule_del(pri, pri->t202_timer);
-			pri->t202_timer = 0;
-		}
+		pri_schedule_del(pri, pri->t202_timer);
+		pri->t202_timer = 0;
 		if (pri->subchannel && (pri->subchannel->tei == tei)) {
 			pri_error(pri, "TEI already assigned (new is %d, current is %d)\n", tei, pri->subchannel->tei);
 			q921_tei_release_and_reacquire(pri);
@@ -1082,10 +1070,8 @@
 					}
 				}
 				/* Reset t200 timer if it was somehow going */
-				if (pri->t200_timer) {
-					pri_schedule_del(pri, pri->t200_timer);
-					pri->t200_timer = 0;
-				}
+				pri_schedule_del(pri, pri->t200_timer);
+				pri->t200_timer = 0;
 				/* Reset and restart t203 timer */
 				reschedule_t203(pri);
 			}

Modified: branches/1.4/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/q931.c?view=diff&rev=1060&r1=1059&r2=1060
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Wed Sep  2 15:04:03 2009
@@ -3116,8 +3116,7 @@
 					"NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s\n",
 					q931_call_state_str(cur->ourcallstate),
 					q931_call_state_str(cur->peercallstate));
-			if (cur->retranstimer)
-				pri_schedule_del(ctrl, cur->retranstimer);
+			pri_schedule_del(ctrl, cur->retranstimer);
 			pri_call_apdu_queue_cleanup(cur);
 			free(cur);
 			return;
@@ -3754,8 +3753,7 @@
 	c->peercallstate = Q931_CALL_STATE_ACTIVE;
 	c->alive = 1;
 	/* Connect request timer */
-	if (c->retranstimer)
-		pri_schedule_del(ctrl, c->retranstimer);
+	pri_schedule_del(ctrl, c->retranstimer);
 	c->retranstimer = 0;
 	if ((c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) && (ctrl->bri || (!ctrl->subchannel)))
 		c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T313], pri_connect_timeout, c);
@@ -3797,8 +3795,7 @@
 		c->causecode = CODE_CCITT;
 		c->causeloc = LOC_PRIV_NET_LOCAL_USER;
 		if (c->acked) {
-			if (c->retranstimer)
-				pri_schedule_del(ctrl, c->retranstimer);
+			pri_schedule_del(ctrl, c->retranstimer);
 			if (!c->t308_timedout) {
 				c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T308], pri_release_timeout, c);
 			} else {
@@ -3845,8 +3842,7 @@
 		c->causecode = CODE_CCITT;
 		c->causeloc = LOC_PRIV_NET_LOCAL_USER;
 		c->sendhangupack = 1;
-		if (c->retranstimer)
-			pri_schedule_del(ctrl, c->retranstimer);
+		pri_schedule_del(ctrl, c->retranstimer);
 		c->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T305], pri_disconnect_timeout, c);
 		return send_message(ctrl, c, Q931_DISCONNECT, disconnect_ies);
 	} else
@@ -4210,8 +4206,7 @@
 		c->progressmask = 0;
 		break;
 	case Q931_CONNECT_ACKNOWLEDGE:
-		if (c->retranstimer)
-			pri_schedule_del(ctrl, c->retranstimer);
+		pri_schedule_del(ctrl, c->retranstimer);
 		c->retranstimer = 0;
 		break;
 	case Q931_RELEASE:
@@ -4220,14 +4215,12 @@
 		c->causecode = -1;
 		c->causeloc = -1;
 		c->aoc_units = -1;
-		if (c->retranstimer)
-			pri_schedule_del(ctrl, c->retranstimer);
+		pri_schedule_del(ctrl, c->retranstimer);
 		c->retranstimer = 0;
 		c->useruserinfo[0] = '\0';
 		break;
 	case Q931_RELEASE_COMPLETE:
-		if (c->retranstimer)
-			pri_schedule_del(ctrl, c->retranstimer);
+		pri_schedule_del(ctrl, c->retranstimer);
 		c->retranstimer = 0;
 		c->useruserinfo[0] = '\0';
 		/* Fall through */
@@ -5102,8 +5095,7 @@
 	struct pri *ctrl = c->pri;
 	int res;
 
-	if (c->retranstimer)
-		pri_schedule_del(ctrl, c->retranstimer);
+	pri_schedule_del(ctrl, c->retranstimer);
 	c->retranstimer = 0;
 	c->useruserinfo[0] = '\0';
 	c->cause = -1;
@@ -5190,8 +5182,7 @@
 				pri_message(ctrl, DBGHEAD "cancel call %d on channel %d in state %d (%s)\n", DBGINFO,
 					cur->cr, cur->channelno, cur->ourcallstate,
 					q931_call_state_str(cur->ourcallstate));
-				if (cur->retranstimer)
-					pri_schedule_del(ctrl, cur->retranstimer);
+				pri_schedule_del(ctrl, cur->retranstimer);
 				cur->retranstimer = pri_schedule_event(ctrl, 0, pri_dl_down_cancelcall, cur);
 			}
 			cur = cur->next;




More information about the svn-commits mailing list