[asterisk-commits] rmudgett: branch rmudgett/hold_retrieve r299179 - /team/rmudgett/hold_retriev...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 20 18:48:10 UTC 2010


Author: rmudgett
Date: Mon Dec 20 12:48:06 2010
New Revision: 299179

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=299179
Log:
Kill the call when we get into a bad hold/retrieve situation.

Modified:
    team/rmudgett/hold_retrieve/channels/sig_pri.c

Modified: team/rmudgett/hold_retrieve/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hold_retrieve/channels/sig_pri.c?view=diff&rev=299179&r1=299178&r2=299179
==============================================================================
--- team/rmudgett/hold_retrieve/channels/sig_pri.c (original)
+++ team/rmudgett/hold_retrieve/channels/sig_pri.c Mon Dec 20 12:48:06 2010
@@ -1095,6 +1095,10 @@
 {
 	int idx;
 
+	if (!call) {
+		/* Cannot find a call without a call. */
+		return -1;
+	}
 	for (idx = 0; idx < pri->numchans; ++idx) {
 		if (pri->pvts[idx] && pri->pvts[idx]->call == call) {
 			/* Found the principle */
@@ -1118,10 +1122,7 @@
 
 	prioffset = PRI_CHANNEL(channel);
 	if (!prioffset || (channel & PRI_HELD_CALL)) {
-		if (!call) {
-			/* Cannot find a call waiting call or held call without a call. */
-			return -1;
-		}
+		/* Find the call waiting call or held call. */
 		return pri_find_principle_by_call(pri, call);
 	}
 
@@ -4028,6 +4029,42 @@
 	}
 }
 
+#if defined(HAVE_PRI_CALL_HOLD)
+/*!
+ * \internal
+ * \brief Kill the call.
+ * \since 1.10
+ *
+ * \param pri Span controller to find interface.
+ * \param call LibPRI opaque call pointer to find.
+ * \param cause Reason call was killed.
+ *
+ * \note Assumes the pvt->pri->lock is already obtained.
+ *
+ * \return Nothing
+ */
+static void sig_pri_kill_call(struct sig_pri_span *pri, q931_call *call, int cause)
+{
+	int chanpos;
+
+	chanpos = pri_find_principle_by_call(pri, call);
+	if (chanpos < 0) {
+		pri_hangup(pri->pri, call, cause);
+		return;
+	}
+	sig_pri_lock_private(pri->pvts[chanpos]);
+	if (!pri->pvts[chanpos]->owner) {
+		pri_hangup(pri->pri, call, cause);
+		pri->pvts[chanpos]->call = NULL;
+		sig_pri_unlock_private(pri->pvts[chanpos]);
+		return;
+	}
+	pri->pvts[chanpos]->owner->hangupcause = cause;
+	pri_queue_control(pri, chanpos, AST_CONTROL_HANGUP);
+	sig_pri_unlock_private(pri->pvts[chanpos]);
+}
+#endif	/* defined(HAVE_PRI_CALL_HOLD) */
+
 /*!
  * \internal
  * \brief Convert the MOH state to string.
@@ -4803,21 +4840,17 @@
 	 */
 	chanpos = pri_find_empty_nobch(pri);
 	if (chanpos < 0) {
-		/*
-		 * Very bad news.  No hold channel available.
-		 * XXX Should seriously consider killing the call.
-		 */
+		/* Very bad news.  No hold channel available. */
 		ast_log(LOG_ERROR,
 			"Span %d: No hold channel available for held call that is on %d/%d\n",
 			pri->span, PRI_SPAN(ev->hold_ack.channel), PRI_CHANNEL(ev->hold_ack.channel));
+		sig_pri_kill_call(pri, ev->hold_ack.call, PRI_CAUSE_RESOURCE_UNAVAIL_UNSPECIFIED);
 		return;
 	}
 	chanpos = pri_fixup_principle(pri, chanpos, ev->hold_ack.call);
 	if (chanpos < 0) {
-		/*
-		 * Should never happen.
-		 * XXX Should seriously consider killing the call.
-		 */
+		/* Should never happen. */
+		sig_pri_kill_call(pri, ev->hold_ack.call, PRI_CAUSE_NORMAL_TEMPORARY_FAILURE);
 		return;
 	}
 
@@ -4855,10 +4888,8 @@
 	}
 	chanpos = pri_fixup_principle(pri, chanpos, ev->hold_rej.call);
 	if (chanpos < 0) {
-		/*
-		 * Should never happen.
-		 * XXX Should seriously consider killing the call.
-		 */
+		/* Should never happen. */
+		sig_pri_kill_call(pri, ev->hold_rej.call, PRI_CAUSE_NORMAL_TEMPORARY_FAILURE);
 		return;
 	}
 
@@ -4968,10 +4999,8 @@
 	}
 	chanpos = pri_fixup_principle(pri, chanpos, ev->retrieve_ack.call);
 	if (chanpos < 0) {
-		/*
-		 * Very bad news.  The channel is already in use.
-		 * XXX Should seriously consider killing the call.
-		 */
+		/* Very bad news.  The channel is already in use. */
+		sig_pri_kill_call(pri, ev->retrieve_ack.call, PRI_CAUSE_REQUESTED_CHAN_UNAVAIL);
 		return;
 	}
 
@@ -5009,10 +5038,8 @@
 	}
 	chanpos = pri_fixup_principle(pri, chanpos, ev->retrieve_rej.call);
 	if (chanpos < 0) {
-		/*
-		 * Should never happen.
-		 * XXX Should seriously consider killing the call.
-		 */
+		/* Should never happen. */
+		sig_pri_kill_call(pri, ev->retrieve_rej.call, PRI_CAUSE_NORMAL_TEMPORARY_FAILURE);
 		return;
 	}
 




More information about the asterisk-commits mailing list