[Asterisk-code-review] res pjsip outbound registration.c: Misc fixes. (asterisk[14])

Richard Mudgett asteriskteam at digium.com
Thu Aug 3 16:26:30 CDT 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/6141


Change subject: res_pjsip_outbound_registration.c: Misc fixes.
......................................................................

res_pjsip_outbound_registration.c: Misc fixes.

* Remove unnecessary CMP_STOP.

* In handle_client_registration() use DEBUG_ATLEAST() to only do work
needed for the debug log message when the debug log message is needed.

* In sip_outbound_registration_state_destroy() check state->registration
for NULL.

Change-Id: I656d0fa11dda0b00048103efb1558e67a426fd80
---
M res/res_pjsip_outbound_registration.c
1 file changed, 12 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/41/6141/1

diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 8a840ff..7b605b9 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -459,7 +459,7 @@
 	struct sip_outbound_registration_state *state = obj;
 	pjsip_param *line = arg;
 
-	return !pj_strcmp2(&line->value, state->client_state->line) ? CMP_MATCH | CMP_STOP : 0;
+	return !pj_strcmp2(&line->value, state->client_state->line) ? CMP_MATCH : 0;
 }
 
 static struct pjsip_param *get_uri_option_line(const void *uri)
@@ -558,20 +558,21 @@
 {
 	RAII_VAR(struct sip_outbound_registration_client_state *, client_state, data, ao2_cleanup);
 	pjsip_tx_data *tdata;
-	pjsip_regc_info info;
-	char server_uri[PJSIP_MAX_URL_SIZE];
-	char client_uri[PJSIP_MAX_URL_SIZE];
 
 	if (client_state->status == SIP_REGISTRATION_STOPPED
 		|| pjsip_regc_register(client_state->client, PJ_FALSE, &tdata) != PJ_SUCCESS) {
 		return 0;
 	}
 
-	pjsip_regc_get_info(client_state->client, &info);
-	ast_copy_pj_str(server_uri, &info.server_uri, sizeof(server_uri));
-	ast_copy_pj_str(client_uri, &info.client_uri, sizeof(client_uri));
-	ast_debug(1, "Outbound REGISTER attempt %u to '%s' with client '%s'\n",
-		client_state->retries + 1, server_uri, client_uri);
+	if (DEBUG_ATLEAST(1)) {
+		pjsip_regc_info info;
+
+		pjsip_regc_get_info(client_state->client, &info);
+		ast_log(LOG_DEBUG, "Outbound REGISTER attempt %u to '%.*s' with client '%.*s'\n",
+			client_state->retries + 1,
+			(int) info.server_uri.slen, info.server_uri.ptr,
+			(int) info.client_uri.slen, info.client_uri.ptr);
+	}
 
 	if (client_state->support_path) {
 		pjsip_supported_hdr *hdr;
@@ -987,7 +988,8 @@
 	struct sip_outbound_registration_state *state = obj;
 
 	ast_debug(3, "Destroying registration state for registration to server '%s' from client '%s'\n",
-			state->registration->server_uri, state->registration->client_uri);
+		state->registration ? state->registration->server_uri : "",
+		state->registration ? state->registration->client_uri : "");
 	ao2_cleanup(state->registration);
 
 	if (!state->client_state) {

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

Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: newchange
Gerrit-Change-Id: I656d0fa11dda0b00048103efb1558e67a426fd80
Gerrit-Change-Number: 6141
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170803/58e01c88/attachment.html>


More information about the asterisk-code-review mailing list