[asterisk-commits] russell: branch russell/issue_8413 r62562 - /team/russell/issue_8413/res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 1 15:04:17 MST 2007


Author: russell
Date: Tue May  1 17:04:16 2007
New Revision: 62562

URL: http://svn.digium.com/view/asterisk?view=rev&rev=62562
Log:
only attempt the callback twice before giving up

Modified:
    team/russell/issue_8413/res/res_features.c

Modified: team/russell/issue_8413/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/russell/issue_8413/res/res_features.c?view=diff&rev=62562&r1=62561&r2=62562
==============================================================================
--- team/russell/issue_8413/res/res_features.c (original)
+++ team/russell/issue_8413/res/res_features.c Tue May  1 17:04:16 2007
@@ -849,7 +849,7 @@
 		ast_set_flag(&(bconfig.features_caller), AST_FEATURE_DISCONNECT);
 		ast_set_flag(&(bconfig.features_callee), AST_FEATURE_DISCONNECT);
 		res = ast_bridge_call(transferer, newchan, &bconfig);
-		if (newchan->_softhangup || newchan->_state != AST_STATE_UP || !transferer->_softhangup) {
+		if (newchan->_softhangup || !transferer->_softhangup) {
 			ast_hangup(newchan);
 			if (ast_stream_and_wait(transferer, xfersound, ""))
 				ast_log(LOG_WARNING, "Failed to play transfer sound!\n");
@@ -900,7 +900,7 @@
 			ast_log(LOG_WARNING, "Failed to play transfer sound!\n");
 		ast_bridge_call_thread_launch(tobj);
 		return -1;      /* XXX meaning the channel is bridged ? */
-	} else if(!ast_check_hangup(transferee)) {
+	} else if (!ast_check_hangup(transferee)) {
 		/* act as blind transfer */
 		if (ast_autoservice_stop(transferee) < 0) {
 			ast_hangup(newchan);
@@ -908,6 +908,8 @@
 		}
 
 		if (!newchan) {
+			unsigned int tries = 0;
+
 			/* newchan wasn't created - we should callback to transferer */
 			if (!ast_exists_extension(transferer, transferer_real_context, transferer->cid.cid_num, 1, transferee->cid.cid_num)) {
 				ast_log(LOG_WARNING, "Extension %s does not exist in context %s - callback failed\n",transferer->cid.cid_num,transferer_real_context);
@@ -919,7 +921,7 @@
 
 			newchan = ast_feature_request_and_dial(transferee, NULL, "Local", ast_best_codec(transferee->nativeformats),
 				callbackto, atxfernoanswertimeout, &outstate, transferee->cid.cid_num, transferee->cid.cid_name, 0);
-			while (!newchan && !atxferdropcall) {
+			while (!newchan && !atxferdropcall && tries < 2) {
 				/* Trying to transfer again */
 				ast_autoservice_start(transferee);
 				ast_indicate(transferee, AST_CONTROL_HOLD);
@@ -932,17 +934,19 @@
 				}
 				if (!newchan) {
 					/* Transfer failed, sleeping */
-					ast_log(LOG_DEBUG, "Sleeping for %d ms before callback.\n", atxferloopdelay);
+					if (option_debug)
+						ast_log(LOG_DEBUG, "Sleeping for %d ms before callback.\n", atxferloopdelay);
 					ast_safe_sleep(transferee, atxferloopdelay);
-					ast_log(LOG_DEBUG, "Trying to callback...\n");
+					if (option_debug)
+						ast_log(LOG_DEBUG, "Trying to callback...\n");
 					newchan = ast_feature_request_and_dial(transferee, NULL, "Local", ast_best_codec(transferee->nativeformats),
 						callbackto, atxfernoanswertimeout, &outstate, transferee->cid.cid_num, transferee->cid.cid_name, 0);
 				}
+				tries++;
 			}
 		}
-		if (!newchan) {
+		if (!newchan)
 			return -1;
-		}
 
 		/* newchan is up, we should prepare transferee and bridge them */
 		if (check_compat(transferee, newchan))



More information about the asterisk-commits mailing list