[asterisk-commits] rmudgett: branch rmudgett/call_waiting r263150 - /team/rmudgett/call_waiting/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 14 10:30:51 CDT 2010


Author: rmudgett
Date: Fri May 14 10:30:47 2010
New Revision: 263150

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=263150
Log:
Move the private channel array sorting into sig_pri.

Modified:
    team/rmudgett/call_waiting/channels/chan_dahdi.c
    team/rmudgett/call_waiting/channels/sig_pri.c

Modified: team/rmudgett/call_waiting/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/call_waiting/channels/chan_dahdi.c?view=diff&rev=263150&r1=263149&r2=263150
==============================================================================
--- team/rmudgett/call_waiting/channels/chan_dahdi.c (original)
+++ team/rmudgett/call_waiting/channels/chan_dahdi.c Fri May 14 10:30:47 2010
@@ -17757,64 +17757,6 @@
 	return 0;
 }
 
-#if defined(HAVE_PRI)
-/*!
- * \internal
- * \brief qsort comparison function.
- * \since 1.8
- *
- * \param left Ptr to sig_pri_chan ptr to compare.
- * \param right Ptr to sig_pri_chan ptr to compare.
- *
- * \retval <0 if left < right.
- * \retval =0 if left == right.
- * \retval >0 if left > right.
- */
-static int dahdi_cmp_pri_chans(const void *left, const void *right)
-{
-	const struct sig_pri_chan *chan_left;
-	const struct sig_pri_chan *chan_right;
-	const struct dahdi_pvt *pvt_left;
-	const struct dahdi_pvt *pvt_right;
-
-	chan_left = *(struct sig_pri_chan **) left;
-	chan_right = *(struct sig_pri_chan **) right;
-	if (!chan_left) {
-		if (!chan_right) {
-			return 0;
-		}
-		return 1;
-	}
-	if (!chan_right) {
-		return -1;
-	}
-	pvt_left = (struct dahdi_pvt *) chan_left->chan_pvt;
-	pvt_right = (struct dahdi_pvt *) chan_right->chan_pvt;
-
-	return pvt_left->channel - pvt_right->channel;
-}
-#endif	/* defined(HAVE_PRI) */
-
-#if defined(HAVE_PRI)
-/*!
- * \internal
- * \brief Sort the PRI B channel private pointer array.
- * \since 1.8
- *
- * \param pri PRI Span controlling structure.
- *
- * \details
- * Since the chan_dahdi.conf file can declare channels in any order, we need to sort
- * the private channel pointer array.
- *
- * \return Nothing
- */
-static void dahdi_sort_pri_chans(struct sig_pri_pri *pri)
-{
-	qsort(&pri->pvts, pri->numchans, sizeof(pri->pvts[0]), dahdi_cmp_pri_chans);
-}
-#endif	/* defined(HAVE_PRI) */
-
 /*!
  * \internal
  * \brief Deep copy struct dahdi_chan_conf.
@@ -18035,7 +17977,6 @@
 		int x;
 		for (x = 0; x < NUM_SPANS; x++) {
 			if (pris[x].pri.pvts[0]) {
-				dahdi_sort_pri_chans(&pris[x].pri);
 				prepare_pri(pris + x);
 				if (sig_pri_start_pri(&pris[x].pri)) {
 					ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1);

Modified: team/rmudgett/call_waiting/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/call_waiting/channels/sig_pri.c?view=diff&rev=263150&r1=263149&r2=263150
==============================================================================
--- team/rmudgett/call_waiting/channels/sig_pri.c (original)
+++ team/rmudgett/call_waiting/channels/sig_pri.c Fri May 14 10:30:47 2010
@@ -5088,12 +5088,64 @@
 	return 1;
 }
 
+/*!
+ * \internal
+ * \brief qsort comparison function.
+ * \since 1.8
+ *
+ * \param left Ptr to sig_pri_chan ptr to compare.
+ * \param right Ptr to sig_pri_chan ptr to compare.
+ *
+ * \retval <0 if left < right.
+ * \retval =0 if left == right.
+ * \retval >0 if left > right.
+ */
+static int sig_pri_cmp_pri_chans(const void *left, const void *right)
+{
+	const struct sig_pri_chan *pvt_left;
+	const struct sig_pri_chan *pvt_right;
+
+	pvt_left = *(struct sig_pri_chan **) left;
+	pvt_right = *(struct sig_pri_chan **) right;
+	if (!pvt_left) {
+		if (!pvt_right) {
+			return 0;
+		}
+		return 1;
+	}
+	if (!pvt_right) {
+		return -1;
+	}
+
+	return pvt_left->channel - pvt_right->channel;
+}
+
+/*!
+ * \internal
+ * \brief Sort the PRI B channel private pointer array.
+ * \since 1.8
+ *
+ * \param pri PRI Span controlling structure.
+ *
+ * \details
+ * Since the chan_dahdi.conf file can declare channels in any order, we need to sort
+ * the private channel pointer array.
+ *
+ * \return Nothing
+ */
+static void sig_pri_sort_pri_chans(struct sig_pri_pri *pri)
+{
+	qsort(&pri->pvts, pri->numchans, sizeof(pri->pvts[0]), sig_pri_cmp_pri_chans);
+}
+
 int sig_pri_start_pri(struct sig_pri_pri *pri)
 {
 	int x;
 	int i;
 
 	ast_mutex_init(&pri->lock);
+
+	sig_pri_sort_pri_chans(pri);
 
 	for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) {
 		if (pri->fds[i] == -1) {




More information about the asterisk-commits mailing list