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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 3 10:27:12 CDT 2013


Author: mmichelson
Date: Fri May  3 10:27:10 2013
New Revision: 387572

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387572
Log:
Add some more debugging/history and fix some bugs.

* All transfer results have unique history and responses
* sip_pvt is locked immediately after transfer is performed
* SIP_GOTREFER flag is cleared at the end of the function
* refer status is set on all transfer outcomes


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=387572&r1=387571&r2=387572
==============================================================================
--- team/mmichelson/sip_transfer/channels/chan_sip.c (original)
+++ team/mmichelson/sip_transfer/channels/chan_sip.c Fri May  3 10:27:10 2013
@@ -26279,10 +26279,6 @@
  * 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.
- *
- * 2) Some debugging and history are gone. While it likely won't be possible
- * to have the same level of debugging and history as before, we should still
- * strive to put in as much as possible.
  */
 static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, uint32_t seqno, int *nounlock)
 {
@@ -26290,6 +26286,7 @@
 	char *refer_to_context = NULL;
 	int res = 0;
 	struct blind_transfer_cb_data cb_data;
+	enum ast_transfer_result transfer_res;
 	RAII_VAR(struct ast_channel *, transferer, NULL, ao2_cleanup);
 
 	if (req->debug) {
@@ -26451,25 +26448,42 @@
 
 	sip_pvt_unlock(p);
 
-	switch (ast_bridge_transfer_blind(transferer, refer_to, refer_to_context, blind_transfer_cb, &cb_data)) {
+	transfer_res = ast_bridge_transfer_blind(transferer, refer_to, refer_to_context, blind_transfer_cb, &cb_data);
+
+	sip_pvt_lock(p);
+
+	switch (transfer_res) {
 	case AST_BRIDGE_TRANSFER_INVALID:
+		res = -1;
+		p->refer->status = REFER_FAILED;
+		transmit_notify_with_sipfrag(p, seqno, "503 Service Unavailable (can't handle one-legged xfers)", TRUE);
+		append_history(p, "Xfer", "Refer failed (only bridged calls).");
+		break;
 	case AST_BRIDGE_TRANSFER_NOT_PERMITTED:
+		res = -1;
+		p->refer->status = REFER_FAILED;
+		transmit_notify_with_sipfrag(p, seqno, "403 Forbidden", TRUE);
+		append_history(p, "Xfer", "Refer failed (bridge does not permit transfers)");
+		break;
 	case AST_BRIDGE_TRANSFER_FAIL:
 		res = -1;
-		transmit_notify_with_sipfrag(p, seqno, "500 Internal Server Error", FALSE);
 		p->refer->status = REFER_FAILED;
+		transmit_notify_with_sipfrag(p, seqno, "500 Internal Server Error", TRUE);
+		append_history(p, "Xfer", "Refer failed (internal error)");
 		break;
 	case AST_BRIDGE_TRANSFER_SUCCESS:
 		res = 0;
-		transmit_notify_with_sipfrag(p, seqno, "200 OK", FALSE);
+		p->refer->status = REFER_200OK;
+		transmit_notify_with_sipfrag(p, seqno, "200 OK", TRUE);
 		ast_set_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);
+		append_history(p, "Xfer", "Refer succeeded.");
 		break;
 	default:
 		break;
 	}
 
+	ast_clear_flag(&p->flags[0], SIP_GOTREFER);
 	ast_party_redirecting_free(&cb_data.redirecting);
-	sip_pvt_lock(p);
 
 handle_refer_cleanup:
 	/* Make sure we exit with the pvt locked */




More information about the asterisk-commits mailing list