[asterisk-commits] mmichelson: branch mmichelson/sip_transfer r387576 - /team/mmichelson/sip_tra...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 3 11:04:22 CDT 2013


Author: mmichelson
Date: Fri May  3 11:04:20 2013
New Revision: 387576

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387576
Log:
Some more cleanup of handle_request_refer.

This gets rid of the goto label since it is no longer
needed. RAII_VAR, you are awesome.


Modified:
    team/mmichelson/sip_transfer/channels/chan_sip.c

Modified: team/mmichelson/sip_transfer/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/sip_transfer/channels/chan_sip.c?view=diff&rev=387576&r1=387575&r2=387576
==============================================================================
--- team/mmichelson/sip_transfer/channels/chan_sip.c (original)
+++ team/mmichelson/sip_transfer/channels/chan_sip.c Fri May  3 11:04:20 2013
@@ -25989,6 +25989,10 @@
  *	If this function is successful, only the transferer pvt lock will remain on return.  Setting nounlock indicates
  *	to handle_request_do() that the pvt's owner it locked does not require an unlock.
  */
+
+/* XXX XXX XXX XXX XXX XXX
+ * This function is COMPLETELY broken at the moment. It *will* crash if called
+ */
 static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *current, struct sip_request *req, uint32_t seqno, int *nounlock)
 {
 	struct sip_dual target;		/* Chan 1: Call from tranferer to Asterisk */
@@ -26271,15 +26275,6 @@
 	We can't destroy dialogs, since we want the call to continue.
 
 	*/
-
-/* XXX First round of cleaning of this function has been completed. The following
- * are things that are missing at the moment and likely should be brought back
- * somehow:
- *
- * 1) local_attended_transfer is completely untouched. Due to the changes in
- * handle_request_refer(), we pass a NULL sip_dual into local_attended_transfer now,
- * so it is completely broken at this point.
- */
 static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, uint32_t seqno, int *nounlock)
 {
 	char *refer_to = NULL;
@@ -26305,8 +26300,7 @@
 			sip_alreadygone(p);
 			pvt_set_needdestroy(p, "outside of dialog");
 		}
-		res = 0;
-		goto handle_refer_cleanup;
+		return 0;
 	}
 
 	/* Check if transfer is allowed from this device */
@@ -26315,24 +26309,21 @@
 		transmit_response(p, "603 Declined (policy)", req);
 		append_history(p, "Xfer", "Refer failed. Allowtransfer == closed.");
 		/* Do not destroy SIP session */
-		res = 0;
-		goto handle_refer_cleanup;
+		return 0;
 	}
 
 	if (!req->ignore && ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
 		/* Already have a pending REFER */
 		transmit_response(p, "491 Request pending", req);
 		append_history(p, "Xfer", "Refer failed. Request pending.");
-		res = 0;
-		goto handle_refer_cleanup;
+		return 0;
 	}
 
 	/* Allocate memory for call transfer data */
 	if (!p->refer && !sip_refer_alloc(p)) {
 		transmit_response(p, "500 Internal Server Error", req);
 		append_history(p, "Xfer", "Refer failed. Memory allocation error.");
-		res = -3;
-		goto handle_refer_cleanup;
+		return -3;
 	}
 
 	res = get_refer_info(p, req);	/* Extract headers */
@@ -26366,8 +26357,7 @@
 			}
 			break;
 		}
-		res = 0;
-		goto handle_refer_cleanup;
+		return 0;
 	}
 
 	if (ast_strlen_zero(p->context)) {
@@ -26390,7 +26380,7 @@
 	/* Is this a repeat of a current request? Ignore it */
 	/* Don't know what else to do right now. */
 	if (req->ignore) {
-		goto handle_refer_cleanup;
+		return 0;
 	}
 
 	/* Get the transferer's channel */
@@ -26411,7 +26401,7 @@
 	if (p->refer->attendedtransfer) {
 		/* both p and p->owner _MUST_ be locked while calling local_attended_transfer */
 		if ((res = local_attended_transfer(p, NULL, req, seqno, nounlock))) {
-			goto handle_refer_cleanup; /* We're done with the transfer */
+			return res;
 		}
 		/* Fall through for remote transfers that we did not find locally */
 		if (sipdebug) {
@@ -26447,9 +26437,7 @@
 	}
 
 	sip_pvt_unlock(p);
-
 	transfer_res = ast_bridge_transfer_blind(transferer, refer_to, refer_to_context, blind_transfer_cb, &cb_data);
-
 	sip_pvt_lock(p);
 
 	switch (transfer_res) {
@@ -26484,9 +26472,6 @@
 
 	ast_clear_flag(&p->flags[0], SIP_GOTREFER);
 	ast_party_redirecting_free(&cb_data.redirecting);
-
-handle_refer_cleanup:
-	/* Make sure we exit with the pvt locked */
 	return res;
 }
 




More information about the asterisk-commits mailing list