[svn-commits] file: branch file/pimp_sip_location r381516 - in /team/file/pimp_sip_location...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 14 17:06:16 CST 2013


Author: file
Date: Thu Feb 14 17:06:12 2013
New Revision: 381516

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381516
Log:
Tweak endpoint reference counting in relation to sessions. The session now increases the refcount itself.

Modified:
    team/file/pimp_sip_location/channels/chan_gulp.c
    team/file/pimp_sip_location/res/res_sip_session.c

Modified: team/file/pimp_sip_location/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_location/channels/chan_gulp.c?view=diff&rev=381516&r1=381515&r2=381516
==============================================================================
--- team/file/pimp_sip_location/channels/chan_gulp.c (original)
+++ team/file/pimp_sip_location/channels/chan_gulp.c Thu Feb 14 17:06:12 2013
@@ -491,7 +491,7 @@
 static struct ast_channel *gulp_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause)
 {
 	char *tmp = ast_strdupa(data), *endpoint_name = NULL, *request_user = NULL;
-	struct ast_sip_endpoint *endpoint = NULL;
+	RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
 	struct ast_sip_session *session = NULL;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(endpoint);
@@ -527,7 +527,6 @@
 	pj_thread_register_check();
 
 	if (!(session = ast_sip_session_create_outgoing(endpoint, args.aor, request_user))) {
-		ao2_cleanup(endpoint);
 		return NULL;
 	}
 

Modified: team/file/pimp_sip_location/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_location/res/res_sip_session.c?view=diff&rev=381516&r1=381515&r2=381516
==============================================================================
--- team/file/pimp_sip_location/res/res_sip_session.c (original)
+++ team/file/pimp_sip_location/res/res_sip_session.c Thu Feb 14 17:06:12 2013
@@ -494,6 +494,7 @@
 	}
 	session->work = ast_sip_create_work();
 	session->endpoint = endpoint;
+	ao2_ref(endpoint, +1);
 	session->legs = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL);
 	if (!session->legs) {
 		return NULL;
@@ -559,14 +560,12 @@
 {
 	struct ast_sip_session *session;
 	pjsip_timer_setting timer;
+	RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);
 
 	/* Create an outgoing session with no default inv_session, multiple may get added later */
 	if (!(session = ast_sip_session_alloc(endpoint, NULL))) {
 		return NULL;
 	}
-
-	/* TODO: Fix up endpoint refcounting */
-	ao2_ref(endpoint, +1);
 
 	pjsip_timer_setting_default(&timer);
 	timer.min_se = endpoint->min_se;
@@ -730,7 +729,7 @@
 	 */
 	pjsip_tx_data *tdata = NULL;
 	pjsip_inv_session *inv_session = NULL;
-	struct ast_sip_endpoint *endpoint = NULL;
+	RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
 	struct ast_sip_session *session = NULL;
 	pjsip_timer_setting timer;
 	pjsip_rdata_sdp_info *sdp_info;
@@ -757,7 +756,7 @@
 		}
 		return;
 	}
-	
+
 	/* From this point on, any calls to pjsip_inv_terminate have the last argument as PJ_TRUE
 	 * so that we will be notified so we can destroy the session properly
 	 */




More information about the svn-commits mailing list