[asterisk-commits] res pjsip session.c: Reorganize ast sip session terminate(). (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 14 13:36:42 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: res_pjsip_session.c: Reorganize ast_sip_session_terminate().
......................................................................


res_pjsip_session.c: Reorganize ast_sip_session_terminate().

Change-Id: I68a2128bcba4830985d2d441e70dfd1ac5bd712b
---
M res/res_pjsip_session.c
1 file changed, 28 insertions(+), 19 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Mark Michelson: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 67cd09d..fad0606 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1794,29 +1794,38 @@
 		response = 603;
 	}
 
-	if ((session->inv_session->state == PJSIP_INV_STATE_CONFIRMED) && session->inv_session->invite_tsx) {
-		ast_debug(3, "Delay sending BYE to %s because of outstanding transaction...\n",
-				ast_sorcery_object_get_id(session->endpoint));
-		/* If this is delayed the only thing that will happen is a BYE request so we don't
-		 * actually need to store the response code for when it happens.
-		 */
-		delay_request(session, NULL, NULL, NULL, 0, DELAYED_METHOD_BYE);
-	} else if (session->inv_session->state == PJSIP_INV_STATE_NULL) {
+	switch (session->inv_session->state) {
+	case PJSIP_INV_STATE_NULL:
 		pjsip_inv_terminate(session->inv_session, response, PJ_TRUE);
-	} else if (((status = pjsip_inv_end_session(session->inv_session, response, NULL, &packet)) == PJ_SUCCESS)
-		&& packet) {
-		struct ast_sip_session_delayed_request *delay;
-
-		/* Flush any delayed requests so they cannot overlap this transaction. */
-		while ((delay = AST_LIST_REMOVE_HEAD(&session->delayed_requests, next))) {
-			ast_free(delay);
+		break;
+	case PJSIP_INV_STATE_CONFIRMED:
+		if (session->inv_session->invite_tsx) {
+			ast_debug(3, "Delay sending BYE to %s because of outstanding transaction...\n",
+					ast_sorcery_object_get_id(session->endpoint));
+			/* If this is delayed the only thing that will happen is a BYE request so we don't
+			 * actually need to store the response code for when it happens.
+			 */
+			delay_request(session, NULL, NULL, NULL, 0, DELAYED_METHOD_BYE);
+			break;
 		}
+		/* Fall through */
+	default:
+		status = pjsip_inv_end_session(session->inv_session, response, NULL, &packet);
+		if (status == PJ_SUCCESS && packet) {
+			struct ast_sip_session_delayed_request *delay;
 
-		if (packet->msg->type == PJSIP_RESPONSE_MSG) {
-			ast_sip_session_send_response(session, packet);
-		} else {
-			ast_sip_session_send_request(session, packet);
+			/* Flush any delayed requests so they cannot overlap this transaction. */
+			while ((delay = AST_LIST_REMOVE_HEAD(&session->delayed_requests, next))) {
+				ast_free(delay);
+			}
+
+			if (packet->msg->type == PJSIP_RESPONSE_MSG) {
+				ast_sip_session_send_response(session, packet);
+			} else {
+				ast_sip_session_send_request(session, packet);
+			}
 		}
+		break;
 	}
 }
 

-- 
To view, visit https://gerrit.asterisk.org/3017
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I68a2128bcba4830985d2d441e70dfd1ac5bd712b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list