[asterisk-commits] tilghman: branch 1.4 r244151 - /branches/1.4/res/res_features.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 1 12:38:41 CST 2010


Author: tilghman
Date: Mon Feb  1 12:38:37 2010
New Revision: 244151

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244151
Log:
When a transferer hangs up during an attended transfer BEFORE the transfer is answered, don't stop playing MOH.

(closes issue #16513)
 Reported by: litnimax
 Patches: 
       atxfer_moh_16513.patch uploaded by gknispel proformatique (license 261)
 Tested by: litnimax

Modified:
    branches/1.4/res/res_features.c

Modified: branches/1.4/res/res_features.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/res/res_features.c?view=diff&rev=244151&r1=244150&r2=244151
==============================================================================
--- branches/1.4/res/res_features.c (original)
+++ branches/1.4/res/res_features.c Mon Feb  1 12:38:37 2010
@@ -967,22 +967,55 @@
 		return FEATURE_RETURN_SUCCESS;
 	}
 
-	if (check_compat(transferer, newchan)) {
-		/* we do mean transferee here, NOT transferer */
-		finishup(transferee);
-		return -1;
-	}
-	memset(&bconfig,0,sizeof(struct ast_bridge_config));
-	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 || !transferer->_softhangup) {
-		ast_hangup(newchan);
-		if (ast_stream_and_wait(transferer, xfersound, transferer->language, ""))
-			ast_log(LOG_WARNING, "Failed to play transfer sound!\n");
-		finishup(transferee);
-		transferer->_softhangup = 0;
-		return FEATURE_RETURN_SUCCESS;
+	if (!ast_check_hangup(transferer)) {
+		if (check_compat(transferer, newchan)) {
+			/* we do mean transferee here, NOT transferer */
+			finishup(transferee);
+			return -1;
+		}
+		memset(&bconfig,0,sizeof(struct ast_bridge_config));
+		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 || !transferer->_softhangup) {
+			ast_hangup(newchan);
+			if (ast_stream_and_wait(transferer, xfersound, transferer->language, ""))
+				ast_log(LOG_WARNING, "Failed to play transfer sound!\n");
+			finishup(transferee);
+			transferer->_softhangup = 0;
+			return FEATURE_RETURN_SUCCESS;
+		}
+	} else {
+		ast_log(LOG_DEBUG, "transferer hangup; outstate = %d\n", outstate);
+		switch (outstate) {
+		case AST_CONTROL_RINGING:
+		{
+			int connected = 0;
+			while (!connected && (ast_waitfor(newchan, -1) >= 0)) {
+				if ((f = ast_read(newchan)) == NULL) {
+					break;
+				}
+				if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_ANSWER) {
+					connected = 1;
+				}
+				ast_frfree(f);
+			}
+			if (!connected) {
+				ast_hangup(newchan);
+				finishup(transferee);
+				return -1;
+			}
+			/* fall through */
+		}
+		case AST_CONTROL_ANSWER:
+			ast_log(LOG_DEBUG, "transferer hangup; callee answered\n");
+			break;
+
+		default:
+			ast_hangup(newchan);
+			finishup(transferee);
+			return FEATURE_RETURN_SUCCESS;
+		}
 	}
 
 	if (check_compat(transferee, newchan)) {




More information about the asterisk-commits mailing list