[libpri-commits] rmudgett: branch rmudgett/issue17865 r1900 - /team/rmudgett/issue17865/

SVN commits to the libpri project libpri-commits at lists.digium.com
Thu Aug 26 20:12:56 CDT 2010


Author: rmudgett
Date: Thu Aug 26 20:12:52 2010
New Revision: 1900

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1900
Log:
Oops. Q.931 says T309 is not to be started if another timer is already running.

Modified:
    team/rmudgett/issue17865/pri_internal.h
    team/rmudgett/issue17865/prisched.c
    team/rmudgett/issue17865/q931.c

Modified: team/rmudgett/issue17865/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/issue17865/pri_internal.h?view=diff&rev=1900&r1=1899&r2=1900
==============================================================================
--- team/rmudgett/issue17865/pri_internal.h (original)
+++ team/rmudgett/issue17865/pri_internal.h Thu Aug 26 20:12:52 2010
@@ -886,6 +886,7 @@
 extern pri_event *pri_schedule_run(struct pri *pri);
 
 extern void pri_schedule_del(struct pri *pri, int ev);
+int pri_schedule_check(struct pri *ctrl, int id, void (*function)(void *data), void *data);
 
 extern pri_event *pri_mkerror(struct pri *pri, char *errstr);
 

Modified: team/rmudgett/issue17865/prisched.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/issue17865/prisched.c?view=diff&rev=1900&r1=1899&r2=1900
==============================================================================
--- team/rmudgett/issue17865/prisched.c (original)
+++ team/rmudgett/issue17865/prisched.c Thu Aug 26 20:12:52 2010
@@ -256,3 +256,32 @@
 			ctrl->sched.num_slots);
 	}
 }
+
+/*!
+ * \brief Is the scheduled event this callback.
+ *
+ * \param ctrl D channel controller.
+ * \param id Scheduled event id to check.
+ * 0 is a disabled/unscheduled event id.
+ * 1 - MAX_SCHED is a valid event id.
+ * \param function Callback function to call when timeout.
+ * \param data Value to give callback function when timeout.
+ *
+ * \return TRUE if scheduled event has the callback.
+ */
+int pri_schedule_check(struct pri *ctrl, int id, void (*function)(void *data), void *data)
+{
+	/* Scheduling runs on master channels only */
+	ctrl = PRI_MASTER(ctrl);
+
+	if (0 < id && id <= ctrl->sched.num_slots) {
+		if (ctrl->sched.timer[id - 1].callback == function
+			&& ctrl->sched.timer[id - 1].data == data) {
+			return 1;
+		}
+	} else if (id) {
+		pri_error(ctrl, "Asked to check sched id %d??? num_slots=%d\n", id,
+			ctrl->sched.num_slots);
+	}
+	return 0;
+}

Modified: team/rmudgett/issue17865/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/issue17865/q931.c?view=diff&rev=1900&r1=1899&r2=1900
==============================================================================
--- team/rmudgett/issue17865/q931.c (original)
+++ team/rmudgett/issue17865/q931.c Thu Aug 26 20:12:52 2010
@@ -8318,7 +8318,7 @@
 	struct pri *ctrl = c->pri;
 
 	if (ctrl->debug & PRI_DEBUG_Q931_STATE)
-		pri_message(ctrl, DBGHEAD "Timed out waiting for data link re-establishment\n", DBGINFO);
+		pri_message(ctrl, "T309 timed out waiting for data link re-establishment\n");
 
 	c->retranstimer = 0;
 	c->cause = PRI_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -8333,7 +8333,7 @@
 	struct pri *ctrl = c->pri;
 
 	if (ctrl->debug & PRI_DEBUG_Q931_STATE)
-		pri_message(ctrl, DBGHEAD "Cancel non active call after data link failure\n", DBGINFO);
+		pri_message(ctrl, "Cancel call after data link failure\n");
 
 	c->retranstimer = 0;
 	c->cause = PRI_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -8357,26 +8357,25 @@
 	switch (event) {
 	case PRI_EVENT_DCHAN_DOWN:
 		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-			pri_message(ctrl, DBGHEAD "link is DOWN\n", DBGINFO);
+			pri_message(ctrl, "DL-RELEASE indication (link is DOWN)\n");
 		}
 		for (cur = *ctrl->callpool; cur; cur = cur->next) {
 			if (!(cur->cr & ~Q931_CALL_REFERENCE_FLAG)) {
 				/* Don't do anything on the global call reference call record. */
 				continue;
 			} else if (cur->ourcallstate == Q931_CALL_STATE_ACTIVE) {
-				/* For a call in Active state, activate T309. */
-				if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-					pri_message(ctrl,
-						DBGHEAD "activate T309 for call %d on channel %d\n", DBGINFO,
-						cur->cr, cur->channelno);
+				/* For a call in Active state, activate T309 only if there is no timer already running. */
+				if (!cur->retranstimer) {
+					if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+						pri_message(ctrl, "Start T309 for call %d on channel %d\n",
+							cur->cr, cur->channelno);
+					}
+					cur->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T309], pri_dl_down_timeout, cur);
 				}
-				pri_schedule_del(ctrl, cur->retranstimer);
-				cur->retranstimer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T309], pri_dl_down_timeout, cur);
 			} else if (cur->ourcallstate != Q931_CALL_STATE_NULL) {
 				/* For a call that is not in Active state, schedule internal clearing of the call 'ASAP' (delay 0). */
 				if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-					pri_message(ctrl,
-						DBGHEAD "cancel call %d on channel %d in state %d (%s)\n", DBGINFO,
+					pri_message(ctrl, "Cancel call %d on channel %d in state %d (%s)\n",
 						cur->cr, cur->channelno, cur->ourcallstate,
 						q931_call_state_str(cur->ourcallstate));
 				}
@@ -8387,20 +8386,21 @@
 		break;
 	case PRI_EVENT_DCHAN_UP:
 		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-			pri_message(ctrl, DBGHEAD "link is UP\n", DBGINFO);
+			pri_message(ctrl, "DL-ESTABLISH indication (link is UP)\n");
 		}
 		for (cur = *ctrl->callpool; cur; cur = cur->next) {
 			if (!(cur->cr & ~Q931_CALL_REFERENCE_FLAG)) {
 				/* Don't do anything on the global call reference call record. */
 				continue;
 			} else if (cur->ourcallstate == Q931_CALL_STATE_ACTIVE) {
-				if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
-					pri_message(ctrl,
-						DBGHEAD "cancel T309 for call %d on channel %d\n", DBGINFO,
-						cur->cr, cur->channelno);
+				if (pri_schedule_check(ctrl, cur->retranstimer, pri_dl_down_timeout, cur)) {
+					if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+						pri_message(ctrl, "Stop T309 for call %d on channel %d\n",
+							cur->cr, cur->channelno);
+					}
+					pri_schedule_del(ctrl, cur->retranstimer);
+					cur->retranstimer = 0;
 				}
-				pri_schedule_del(ctrl, cur->retranstimer);
-				cur->retranstimer = 0;
 				winner = q931_find_winning_call(cur);
 				if (winner) {
 					q931_status(ctrl, winner, PRI_CAUSE_NORMAL_UNSPECIFIED);




More information about the libpri-commits mailing list