[asterisk-commits] mmichelson: branch mmichelson/forward-loop r87061 - /team/mmichelson/forward-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 25 15:32:38 CDT 2007


Author: mmichelson
Date: Thu Oct 25 15:32:38 2007
New Revision: 87061

URL: http://svn.digium.com/view/asterisk?view=rev&rev=87061
Log:
Removed a redundant section in app_dial that dealt with call forwarding, and added lines
to remove the datastore from the channel once we're finished with it and to free it so that
the datastore doesn't stay on the channel through the call. Keeping it around could cause problems
if someone attempts to transfer to an interface which had been dialed initially. Or at least it appears
that way.


Modified:
    team/mmichelson/forward-loop/apps/app_dial.c
    team/mmichelson/forward-loop/apps/app_queue.c

Modified: team/mmichelson/forward-loop/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/forward-loop/apps/app_dial.c?view=diff&rev=87061&r1=87060&r2=87061
==============================================================================
--- team/mmichelson/forward-loop/apps/app_dial.c (original)
+++ team/mmichelson/forward-loop/apps/app_dial.c Thu Oct 25 15:32:38 2007
@@ -831,6 +831,7 @@
 	);
 	struct ast_flags opts = { 0, };
 	char *opt_args[OPT_ARG_ARRAY_SIZE];
+	struct ast_datastore *datastore;
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Dial requires an argument (technology/number)\n");
@@ -1096,7 +1097,6 @@
 		/* find if we already dialed this interface */
 		int dialed = 0;
 		struct ast_dialed_interface *di;
-		struct ast_datastore *datastore;
 		AST_LIST_HEAD(, ast_dialed_interface) *dialed_interfaces;
 		if (!number) {
 			ast_log(LOG_WARNING, "Dial argument takes format (technology/[device:]number1)\n");
@@ -1162,53 +1162,6 @@
 		}
 		AST_LIST_UNLOCK(dialed_interfaces);
 		pbx_builtin_setvar_helper(tmp->chan, "DIALEDPEERNUMBER", numsubst);
-#if 0		
-		if (!ast_strlen_zero(tmp->chan->call_forward)) {
-			char tmpchan[256];
-			char *stuff;
-			char *tech;
-			ast_copy_string(tmpchan, tmp->chan->call_forward, sizeof(tmpchan));
-			if ((stuff = strchr(tmpchan, '/'))) {
-				*stuff++ = '\0';
-				tech = tmpchan;
-			} else {
-				snprintf(tmpchan, sizeof(tmpchan), "%s@%s", tmp->chan->call_forward, tmp->chan->context);
-				stuff = tmpchan;
-				tech = "Local";
-			}
-			tmp->forwards++;
-			if (tmp->forwards < AST_MAX_FORWARDS) {
-				if (option_verbose > 2)
-					ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
-				ast_hangup(tmp->chan);
-				/* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
-				if (ast_test_flag(&opts, OPT_IGNORE_FORWARDING)) {
-					tmp->chan = NULL;
-					cause = AST_CAUSE_BUSY;
-					if (option_verbose > 2)
-						ast_verbose(VERBOSE_PREFIX_3 "Forwarding %s to '%s/%s' prevented.\n", chan->name, tech, stuff);
-				} else {
-					tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause);
-					ast_log(LOG_DEBUG, "Requester 1 got channel %p\n", tmp->chan);
-				}
-				if (!tmp->chan)
-					ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
-				else
-					ast_channel_inherit_variables(chan, tmp->chan);
-			} else {
-				if (option_verbose > 2)
-					ast_verbose(VERBOSE_PREFIX_3 "Too many forwards from %s\n", tmp->chan->name);
-				ast_hangup(tmp->chan);
-				tmp->chan = NULL;
-				cause = AST_CAUSE_CONGESTION;
-			}
-			if (!tmp->chan) {
-				HANDLE_CAUSE(cause, chan);
-				free(tmp);
-				continue;
-			}
-		}
-#endif
 
 		/* Setup outgoing SDP to match incoming one */
 		ast_rtp_make_compatible(tmp->chan, chan, !outgoing && !rest);
@@ -1335,7 +1288,9 @@
 
 	time(&start_time);
 	peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
-	
+
+	ast_channel_datastore_remove(chan, datastore);
+	ast_channel_datastore_free(datastore);
 	if (!peer) {
 		if (result) {
 			res = result;

Modified: team/mmichelson/forward-loop/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/forward-loop/apps/app_queue.c?view=diff&rev=87061&r1=87060&r2=87061
==============================================================================
--- team/mmichelson/forward-loop/apps/app_queue.c (original)
+++ team/mmichelson/forward-loop/apps/app_queue.c Thu Oct 25 15:32:38 2007
@@ -2499,6 +2499,7 @@
 	int forwardsallowed = 1;
 	int callcompletedinsl;
 	struct ao2_iterator memi;
+	struct ast_datastore *datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL);
 
 	memset(&bridge_config, 0, sizeof(bridge_config));
 	time(&now);
@@ -2554,7 +2555,6 @@
 	memi = ao2_iterator_init(qe->parent->members, 0);
 	while ((cur = ao2_iterator_next(&memi))) {
 		struct callattempt *tmp = ast_calloc(1, sizeof(*tmp));
-		struct ast_datastore *datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL);
 		struct ast_dialed_interface *di;
 		int dialed = 0;
 		AST_LIST_HEAD(, ast_dialed_interface) *dialed_interfaces;
@@ -2623,6 +2623,8 @@
 	if (use_weight)
 		AST_LIST_UNLOCK(&queues);
 	lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT), forwardsallowed);
+	ast_channel_datastore_remove(qe->chan, datastore);
+	ast_channel_datastore_free(datastore);
 	ast_mutex_lock(&qe->parent->lock);
 	if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY) {
 		store_next(qe, outgoing);




More information about the asterisk-commits mailing list