[asterisk-commits] rmudgett: branch 12 r410995 - /branches/12/res/res_pjsip_registrar.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 21 11:02:00 CDT 2014


Author: rmudgett
Date: Fri Mar 21 11:01:56 2014
New Revision: 410995

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410995
Log:
res_pjsip_registrar.c: Miscellaneous cleanup in rx_task().

* Fix variable shadowing of 'updated' by renaming it to 'contact_update'.

* Checked 'contact_update' for ast_sorcery_copy() failure.

* Removed silly use of RAII_VAR() for 'contact_update'.

Modified:
    branches/12/res/res_pjsip_registrar.c

Modified: branches/12/res/res_pjsip_registrar.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_registrar.c?view=diff&rev=410995&r1=410994&r2=410995
==============================================================================
--- branches/12/res/res_pjsip_registrar.c (original)
+++ branches/12/res/res_pjsip_registrar.c Fri Mar 21 11:01:56 2014
@@ -518,18 +518,26 @@
 					expiration,
 					user_agent);
 		} else if (expiration) {
-			RAII_VAR(struct ast_sip_contact *, updated, ast_sorcery_copy(ast_sip_get_sorcery(), contact), ao2_cleanup);
-			updated->expiration_time = ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1));
-			updated->qualify_frequency = task_data->aor->qualify_frequency;
-			updated->authenticate_qualify = task_data->aor->authenticate_qualify;
+			struct ast_sip_contact *contact_update;
+
+			contact_update = ast_sorcery_copy(ast_sip_get_sorcery(), contact);
+			if (!contact_update) {
+				ast_log(LOG_ERROR, "Failed to update contact '%s' expiration time to %d seconds.\n",
+					contact->uri, expiration);
+				continue;
+			}
+
+			contact_update->expiration_time = ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1));
+			contact_update->qualify_frequency = task_data->aor->qualify_frequency;
+			contact_update->authenticate_qualify = task_data->aor->authenticate_qualify;
 			if (path_str) {
-				ast_string_field_set(updated, path, ast_str_buffer(path_str));
+				ast_string_field_set(contact_update, path, ast_str_buffer(path_str));
 			}
 			if (user_agent) {
-				ast_string_field_set(updated, user_agent, user_agent);
+				ast_string_field_set(contact_update, user_agent, user_agent);
 			}
 
-			ast_sip_location_update_contact(updated);
+			ast_sip_location_update_contact(contact_update);
 			ast_debug(3, "Refreshed contact '%s' on AOR '%s' with new expiration of %d seconds\n",
 				contact_uri, aor_name, expiration);
 			ast_test_suite_event_notify("AOR_CONTACT_REFRESHED",
@@ -540,7 +548,8 @@
 					contact_uri,
 					aor_name,
 					expiration,
-					updated->user_agent);
+					contact_update->user_agent);
+			ao2_cleanup(contact_update);
 		} else {
 			/* We want to report the user agent that was actually in the removed contact */
 			user_agent = ast_strdupa(contact->user_agent);




More information about the asterisk-commits mailing list