[svn-commits] crichter: trunk r121770 - in /trunk: ./ channels/misdn/isdn_lib.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jun 11 06:52:19 CDT 2008


Author: crichter
Date: Wed Jun 11 06:52:18 2008
New Revision: 121770

URL: http://svn.digium.com/view/asterisk?view=rev&rev=121770
Log:
Merged revisions 121751 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r121751 | crichter | 2008-06-11 11:28:04 +0200 (Mi, 11 Jun 2008) | 1 line

fixed issue with previous commit, the find_free_channel test for channels which where inuse was broken.
........

Modified:
    trunk/   (props changed)
    trunk/channels/misdn/isdn_lib.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?view=diff&rev=121770&r1=121769&r2=121770
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Wed Jun 11 06:52:18 2008
@@ -3121,12 +3121,18 @@
 	struct timeval now;
 	gettimeofday(&now, NULL);
 	if (!bc->in_use) {
-		if (bc->last_used.tv_sec < now.tv_sec) {
-			cb_log(0,bc->port, "channel with stid:%x for one second still in use!\n", bc->b_stid);
+		if ( bc->last_used.tv_sec == now.tv_sec ) {
+			cb_log(2,bc->port, "channel with stid:%x for one second still in use! (n:%d lu:%d)\n", bc->b_stid, now.tv_sec, bc->last_used.tv_sec);
 			return 1;
 		}
-	}
-	return 0;
+		
+
+		cb_log(3,bc->port, "channel with stid:%x not in use!\n", bc->b_stid);
+		return 0;
+	}
+	
+	cb_log(2,bc->port, "channel with stid:%x in use!\n", bc->b_stid);
+	return 1;
 }
 
 
@@ -3175,9 +3181,15 @@
 			if (channel > 0) {
 				if (channel <= stack->b_num) {
 					for (i = 0; i < stack->b_num; i++) {
-						if ( test_inuse(&stack->bc[i]) && stack->bc[i].channel == channel) {
-							cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
-							return NULL;
+						if ( stack->bc[i].channel == channel) {
+							if (test_inuse(&stack->bc[i])) { 
+								cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
+								return NULL;
+
+							} else {
+								prepare_bc(&stack->bc[i], channel);
+								return &stack->bc[i];
+							}
 						}
 					}
 				} else {
@@ -3190,7 +3202,7 @@
 
 			if (dec) {
 				for (i = maxnum-1; i>=0; i--) {
-					if (test_inuse(&stack->bc[i])) {
+					if (!test_inuse(&stack->bc[i])) {
 						/* 3. channel on bri means CW*/
 						if (!stack->pri && i==stack->b_num)
 							stack->bc[i].cw=1;
@@ -3202,7 +3214,7 @@
 				}
 			} else {
 				for (i = 0; i <maxnum; i++) {
-					if (test_inuse(&stack->bc[i])) {
+					if (!test_inuse(&stack->bc[i])) {
 						/* 3. channel on bri means CW*/
 						if (!stack->pri && i==stack->b_num)
 							stack->bc[i].cw=1;




More information about the svn-commits mailing list