[Asterisk-cvs] asterisk/res res_features.c,1.6,1.7

markster at lists.digium.com markster at lists.digium.com
Fri Aug 6 10:08:13 CDT 2004


Update of /usr/cvsroot/asterisk/res
In directory localhost.localdomain:/tmp/cvs-serv25093/res

Modified Files:
	res_features.c 
Log Message:
Keep track of timelimit across entries to ast_channel_bridge (bug #2222)


Index: res_features.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_features.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- res_features.c	3 Aug 2004 14:09:48 -0000	1.6
+++ res_features.c	6 Aug 2004 13:54:07 -0000	1.7
@@ -262,9 +262,11 @@
 	struct ast_channel *who;
 	char newext[256], *ptr;
 	int res;
+	int diff;
 	struct ast_option_header *aoh;
 	struct ast_channel *transferer;
 	struct ast_channel *transferee;
+	struct timeval start, end;
 	char *transferer_real_context;
 	int allowdisconnect_in,allowdisconnect_out,allowredirect_in,allowredirect_out;
 
@@ -291,7 +293,23 @@
 		peer->cdr = NULL;
 	}
 	for (;;) {
-	  res = ast_channel_bridge(chan,peer,config,&f, &who);
+		if (config->timelimit)
+			gettimeofday(&start, NULL);
+		res = ast_channel_bridge(chan,peer,config,&f, &who);
+		if (config->timelimit) {
+			/* Update time limit for next pass */
+			gettimeofday(&end, NULL);
+			diff = (end.tv_sec - start.tv_sec) * 1000;
+			diff += (end.tv_usec - start.tv_usec) / 1000;
+			config->timelimit -= diff;
+			if (config->timelimit <=0) {
+				/* We ran out of time */
+				config->timelimit = 0;
+				who = chan;
+				f = NULL;
+				res = 0;
+			}
+		}
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Bridge failed on channels %s and %s\n", chan->name, peer->name);
 			return -1;




More information about the svn-commits mailing list