[svn-commits] twilson: branch 1.6.0 r153265 - in /branches/1.6.0: ./ apps/ include/asterisk...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Oct 31 16:49:24 CDT 2008


Author: twilson
Date: Fri Oct 31 16:49:23 2008
New Revision: 153265

URL: http://svn.digium.com/view/asterisk?view=rev&rev=153265
Log:
Merged revisions 153181 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r153181 | twilson | 2008-10-31 13:55:33 -0500 (Fri, 31 Oct 2008) | 5 lines
  
  Recent CDR fixes moved execution of the 'h' exten into the bridging code, so variables that were set after ast_bridge_call was called would not show up in the 'h' exten.  Added a callback function to handle setting variables, etc. from w/in the bridging code.  Calls back into a nested function within the function calling ast_bridge_call
  
  (closes issue #13793)
  Reported by: greenfieldtech
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/apps/app_dial.c
    branches/1.6.0/apps/app_followme.c
    branches/1.6.0/apps/app_queue.c
    branches/1.6.0/include/asterisk/channel.h
    branches/1.6.0/main/features.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_dial.c?view=diff&rev=153265&r1=153264&r2=153265
==============================================================================
--- branches/1.6.0/apps/app_dial.c (original)
+++ branches/1.6.0/apps/app_dial.c Fri Oct 31 16:49:23 2008
@@ -1238,7 +1238,6 @@
 	int sentringing = 0, moh = 0;
 	const char *outbound_group = NULL;
 	int result = 0;
-	time_t start_time;
 	char *parse;
 	int opermode = 0;
 	AST_DECLARE_APP_ARGS(args,
@@ -1594,7 +1593,6 @@
 		}
 	}
 
-	time(&start_time);
 	peer = wait_for_answer(chan, outgoing, &to, peerflags, &pa, &num, &result);
 
 	/* The ast_channel_datastore_remove() function could fail here if the
@@ -1616,10 +1614,9 @@
 		/* almost done, although the 'else' block is 400 lines */
 	} else {
 		const char *number;
-		time_t end_time, answer_time = time(NULL);
-		char toast[80]; /* buffer to set variables */
 
 		strcpy(pa.status, "ANSWER");
+		pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
 		/* Ah ha!  Someone answered within the desired timeframe.  Of course after this
 		   we will always return with -1 so that it is hung up properly after the
 		   conversation.  */
@@ -1837,11 +1834,31 @@
 				res = ast_dtmf_stream(chan, peer, dtmfcalling, 250, 0);
 			}
 		}
-		
+
 		if (res) { /* some error */
 			res = -1;
-			end_time = time(NULL);
 		} else {
+			auto void end_bridge_callback(void);
+			void end_bridge_callback (void)
+			{
+				char buf[80];
+				time_t end;
+
+				time(&end);
+
+				ast_channel_lock(chan);
+				if (chan->cdr->answer.tv_sec) {
+					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+					pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+				}
+
+				if (chan->cdr->start.tv_sec) {
+					snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+					pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+				}
+				ast_channel_unlock(chan);
+			}
+
 			if (ast_test_flag64(peerflags, OPT_CALLEE_TRANSFER))
 				ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
 			if (ast_test_flag64(peerflags, OPT_CALLER_TRANSFER))
@@ -1865,6 +1882,8 @@
 			if (ast_test_flag64(peerflags, OPT_GO_ON))
 				ast_set_flag(&(config.features_caller), AST_FEATURE_NO_H_EXTEN);
 
+			config.end_bridge_callback = end_bridge_callback;
+
 			if (moh) {
 				moh = 0;
 				ast_moh_stop(chan);
@@ -1895,13 +1914,7 @@
 				ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0);
 			}
 			res = ast_bridge_call(chan, peer, &config);
-			end_time = time(NULL);
-			snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
-			pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast);
-		}
-
-		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
-		pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
+		}
 
 		if (ast_test_flag64(&opts, OPT_PEER_H)) {
 			ast_log(LOG_NOTICE, "PEER context: %s; PEER exten: %s;  PEER priority: %d\n",

Modified: branches/1.6.0/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_followme.c?view=diff&rev=153265&r1=153264&r2=153265
==============================================================================
--- branches/1.6.0/apps/app_followme.c (original)
+++ branches/1.6.0/apps/app_followme.c Fri Oct 31 16:49:23 2008
@@ -146,7 +146,6 @@
 });
 
 static int ynlongest = 0;
-static time_t start_time, answer_time, end_time;
 
 static const char *featuredigittostr;
 static int featuredigittimeout = 5000;		/*!< Feature Digit Timeout */
@@ -770,7 +769,6 @@
 	while (nm) {
 
 		ast_debug(2, "Number %s timeout %ld\n", nm->number,nm->timeout);
-		time(&start_time);
 
 		number = ast_strdupa(nm->number);
 		ast_debug(3, "examining %s\n", number);
@@ -889,7 +887,6 @@
 	int duration = 0;
 	struct ast_channel *caller;
 	struct ast_channel *outbound;
-	static char toast[80];
 	
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(followmeid);
@@ -989,6 +986,27 @@
 			ast_stream_and_wait(chan, targs.sorryprompt, "");
 		res = 0;
 	} else {
+		auto void end_bridge_callback(void);
+		void end_bridge_callback (void)
+		{
+			char buf[80];
+			time_t end;
+
+			time(&end);
+
+			ast_channel_lock(chan);
+			if (chan->cdr->answer.tv_sec) {
+				snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+				pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+			}
+
+			if (chan->cdr->start.tv_sec) {
+				snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+				pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+			}
+			ast_channel_unlock(chan);
+		}
+
 		caller = chan;
 		outbound = targs.outbound;
 		/* Bridge the two channels. */
@@ -997,7 +1015,8 @@
 		ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
 		ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
 		ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
-		
+		config.end_bridge_callback = end_bridge_callback;
+
 		ast_moh_stop(caller);
 		/* Be sure no generators are left on it */
 		ast_deactivate_generator(caller);
@@ -1008,13 +1027,7 @@
 			ast_hangup(outbound);
 			goto outrun;
 		}
-		time(&answer_time);
 		res = ast_bridge_call(caller,outbound,&config);
-		time(&end_time);
-		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
-		pbx_builtin_setvar_helper(caller, "DIALEDTIME", toast);
-		snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
-		pbx_builtin_setvar_helper(caller, "ANSWEREDTIME", toast);
 		if (outbound)
 			ast_hangup(outbound);
 	}

Modified: branches/1.6.0/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_queue.c?view=diff&rev=153265&r1=153264&r2=153265
==============================================================================
--- branches/1.6.0/apps/app_queue.c (original)
+++ branches/1.6.0/apps/app_queue.c Fri Oct 31 16:49:23 2008
@@ -3211,6 +3211,13 @@
 	int callcompletedinsl;
 	struct ao2_iterator memi;
 	struct ast_datastore *datastore;
+	auto void end_bridge_callback(void);
+	void end_bridge_callback(void)
+	{
+		ao2_lock(qe->parent);
+		set_queue_variables(qe);
+		ao2_unlock(qe->parent);
+	}
 
 	ast_channel_lock(qe->chan);
 	datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL);
@@ -3280,6 +3287,8 @@
 			break;
 
 		}
+
+	bridge_config.end_bridge_callback = end_bridge_callback;
 
 	/* Hold the lock while we setup the outgoing calls */
 	if (use_weight)

Modified: branches/1.6.0/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk/channel.h?view=diff&rev=153265&r1=153264&r2=153265
==============================================================================
--- branches/1.6.0/include/asterisk/channel.h (original)
+++ branches/1.6.0/include/asterisk/channel.h Fri Oct 31 16:49:23 2008
@@ -620,6 +620,7 @@
 	const char *start_sound;
 	int firstpass;
 	unsigned int flags;
+	void (* end_bridge_callback)(void);   /*!< A callback that is called after a bridge attempt */
 };
 
 struct chanmon;

Modified: branches/1.6.0/main/features.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/features.c?view=diff&rev=153265&r1=153264&r2=153265
==============================================================================
--- branches/1.6.0/main/features.c (original)
+++ branches/1.6.0/main/features.c Fri Oct 31 16:49:23 2008
@@ -1907,6 +1907,7 @@
 	int diff;
 	int hasfeatures=0;
 	int hadfeatures=0;
+	int autoloopflag;
 	struct ast_option_header *aoh;
 	struct ast_bridge_config backup_config;
 	struct ast_cdr *bridge_cdr = NULL;
@@ -2170,7 +2171,13 @@
 	new_chan_cdr = pick_unlocked_cdr(chan->cdr); /* the proper chan cdr, if there are forked cdrs */
 	new_peer_cdr = pick_unlocked_cdr(peer->cdr); /* the proper chan cdr, if there are forked cdrs */
 
-	if (!ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
+	if (res != AST_PBX_KEEPALIVE && config->end_bridge_callback) {
+		config->end_bridge_callback();
+	}
+
+	autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
+	ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
+	if (res != AST_PBX_KEEPALIVE && !ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
 		struct ast_cdr *swapper;
 		char savelastapp[AST_MAX_EXTENSION];
 		char savelastdata[AST_MAX_EXTENSION];
@@ -2214,6 +2221,7 @@
 		ast_copy_string(bridge_cdr->lastapp, savelastapp, sizeof(bridge_cdr->lastapp));
 		ast_copy_string(bridge_cdr->lastdata, savelastdata, sizeof(bridge_cdr->lastdata));
 	}
+	ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
 
 	/* obey the NoCDR() wishes. */
  	if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))




More information about the svn-commits mailing list