[asterisk-commits] mmichelson: branch mmichelson/pool_shark2 r381816 - /team/mmichelson/pool_sha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 19 20:57:33 CST 2013


Author: mmichelson
Date: Tue Feb 19 20:57:29 2013
New Revision: 381816

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381816
Log:
Clean up reference counting in the authenticator.


Modified:
    team/mmichelson/pool_shark2/res/res_sip/sip_distributor.c

Modified: team/mmichelson/pool_shark2/res/res_sip/sip_distributor.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pool_shark2/res/res_sip/sip_distributor.c?view=diff&rev=381816&r1=381815&r2=381816
==============================================================================
--- team/mmichelson/pool_shark2/res/res_sip/sip_distributor.c (original)
+++ team/mmichelson/pool_shark2/res/res_sip/sip_distributor.c Tue Feb 19 20:57:29 2013
@@ -55,7 +55,7 @@
 
 	if (!endpoint && !is_ack) {
 		/* XXX When we do an alwaysauthreject-like option, we'll need to take that into account
-		 * for this option. Either that, or have a pseudo-endpoint to pass along so that authentication
+		 * for this response. Either that, or have a pseudo-endpoint to pass along so that authentication
 		 * will fail
 		 */
 		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 403, NULL, NULL, NULL);
@@ -67,8 +67,8 @@
 
 static pj_bool_t authenticate(pjsip_rx_data *rdata)
 {
-	pj_bool_t res = PJ_FALSE;
-	struct ast_sip_endpoint *endpoint = ast_pjsip_rdata_get_endpoint(rdata);
+	RAII_VAR(struct ast_sip_endpoint *, endpoint, ast_pjsip_rdata_get_endpoint(rdata), ao2_cleanup);
+
 	ast_assert(endpoint != NULL);
 
 	if (ast_sip_requires_authentication(endpoint, rdata)) {
@@ -78,24 +78,19 @@
 		case AST_SIP_AUTHENTICATION_CHALLENGE:
 			/* Send the 401 we created for them */
 			pjsip_endpt_send_response2(ast_sip_get_pjsip_endpoint(), rdata, tdata, NULL, NULL);
-			res = PJ_TRUE;
-			goto end;
+			return PJ_TRUE;
 		case AST_SIP_AUTHENTICATION_SUCCESS:
-			res = PJ_FALSE;
-			goto end;
+			return PJ_FALSE;
 		case AST_SIP_AUTHENTICATION_FAILED:
 			pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 403, NULL, NULL, NULL);
-			res = PJ_TRUE;
-			goto end;
+			return PJ_TRUE;
 		case AST_SIP_AUTHENTICATION_ERROR:
 			pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
-			res = PJ_TRUE;
-			goto end;
+			return PJ_TRUE;
 		}
 	}
-end:
-	ao2_cleanup(endpoint);
-	return res;
+
+	return PJ_FALSE;
 }
 
 pjsip_module auth_mod = {




More information about the asterisk-commits mailing list