[asterisk-commits] rizzo: branch rizzo/astobj2 r51282 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 19 02:06:48 MST 2007


Author: rizzo
Date: Fri Jan 19 03:06:47 2007
New Revision: 51282

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51282
Log:
merge from trunk 50469,

Remove check for channel state as it can definitely be something other then ring, and also clean up the code a bit. This should solve the parking issues and maybe some attended transfer issues people have been seeing.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=51282&r1=51281&r2=51282
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Jan 19 03:06:47 2007
@@ -14306,7 +14306,6 @@
 					/* Chan 2: Call from Asterisk to target */
 	int res = 0;
 	struct sip_pvt *targetcall_pvt;
-	int error = 0;
 
 	/* Check if the call ID of the replaces header does exist locally */
 	if (!(targetcall_pvt = get_sip_pvt_byid_locked(transferer->refer->replaces_callid, transferer->refer->replaces_callid_totag, 
@@ -14334,38 +14333,32 @@
 	if (!targetcall_pvt->owner) {	/* No active channel */
 		if (option_debug > 3)
 			ast_log(LOG_DEBUG, "SIP attended transfer: Error: No owner of target call\n");
-		error = 1;
-	}
+		/* Cancel transfer */
+		transmit_notify_with_sipfrag(transferer, seqno, "503 Service Unavailable", TRUE);
+  	        append_history(transferer, "Xfer", "Refer failed");
+  	        ast_clear_flag(&transferer->flags[0], SIP_GOTREFER);
+  	        transferer->refer->status = REFER_FAILED;
+  	        sip_pvt_unlock(targetcall_pvt);
+  	        ast_channel_unlock(current->chan1);
+  	        ast_channel_unlock(targetcall_pvt->owner);
+  	        return -1;
+	}
+
 	/* We have a channel, find the bridge */
 	target.chan1 = targetcall_pvt->owner;				/* Transferer to Asterisk */
 
-	if (!error) {
-		target.chan2 = ast_bridged_channel(targetcall_pvt->owner);	/* Asterisk to target */
-
-		if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
-			/* Wrong state of new channel */
-			if (option_debug > 3) {
-				if (target.chan2) 
-					ast_log(LOG_DEBUG, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
-				else if (target.chan1->_state != AST_STATE_RING)
-					ast_log(LOG_DEBUG, "SIP attended transfer: Error: No target channel\n");
-				else
-					ast_log(LOG_DEBUG, "SIP attended transfer: Attempting transfer in ringing state\n");
-			}
-			if (target.chan1->_state != AST_STATE_RING)
-				error = 1;
-		}
-	}
-	if (error) {	/* Cancel transfer */
-		transmit_notify_with_sipfrag(transferer, seqno, "503 Service Unavailable", TRUE);
-		append_history(transferer, "Xfer", "Refer failed");
-		ast_clear_flag(&transferer->flags[0], SIP_GOTREFER);	
-		transferer->refer->status = REFER_FAILED;
-		sip_pvt_unlock(targetcall_pvt);
-		pvt_unref(targetcall_pvt);
-		ast_channel_unlock(current->chan1);
-		ast_channel_unlock(target.chan1);
-		return -1;
+	target.chan2 = ast_bridged_channel(targetcall_pvt->owner);	/* Asterisk to target */
+
+	if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
+		/* Wrong state of new channel */
+		if (option_debug > 3) {
+			if (target.chan2) 
+				ast_log(LOG_DEBUG, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
+			else if (target.chan1->_state != AST_STATE_RING)
+				ast_log(LOG_DEBUG, "SIP attended transfer: Error: No target channel\n");
+			else
+				ast_log(LOG_DEBUG, "SIP attended transfer: Attempting transfer in ringing state\n");
+		}
 	}
 
 	/* Transfer */



More information about the asterisk-commits mailing list