[Asterisk-code-review] res pjsip outbound registration.c: Filter redundant statsd r... (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Thu Dec 1 13:34:42 CST 2016


Richard Mudgett has uploaded a new change for review. ( https://gerrit.asterisk.org/4543 )

Change subject: res_pjsip_outbound_registration.c: Filter redundant statsd reporting.
......................................................................

res_pjsip_outbound_registration.c: Filter redundant statsd reporting.

Increasing the testsuite shutdown timeout before forcibly killing
Asterisk allowed more events to be sent out.  Some tests failed as
a result.  The tests/channels/pjsip/statsd/registrations failed
because we now get the statsd events that a comment in the test
configuration stated couldn't be intercepted.  Unfortunately, we
get a variable number of events because of internal status state
transition races generating redundant statsd events.

We were reporting redundant statsd PJSIP.registrations.state changes
for internal state changes that equated to the same thing publicly.

* Made update_client_state_status() filter out redundant statsd
updates.

ASTERISK-26527

Change-Id: If851c7d514bb530d9226e4941ba97dcf52000646
---
M res/res_pjsip_outbound_registration.c
1 file changed, 18 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/43/4543/1

diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 29701a1..d486ccd 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -627,15 +627,30 @@
 
 static void update_client_state_status(struct sip_outbound_registration_client_state *client_state, enum sip_outbound_registration_status status)
 {
+	const char *status_old;
+	const char *status_new;
+
 	if (client_state->status == status) {
+		/* Status state did not change at all. */
+		return;
+	}
+
+	status_old = sip_outbound_registration_status_str(client_state->status);
+	status_new = sip_outbound_registration_status_str(status);
+	client_state->status = status;
+
+	if (!strcmp(status_old, status_new)) {
+		/*
+		 * The internal status state may have changed but the status
+		 * state we tell the world did not change at all.
+		 */
 		return;
 	}
 
 	ast_statsd_log_string_va("PJSIP.registrations.state.%s", AST_STATSD_GAUGE, "-1", 1.0,
-		sip_outbound_registration_status_str(client_state->status));
+		status_old);
 	ast_statsd_log_string_va("PJSIP.registrations.state.%s", AST_STATSD_GAUGE, "+1", 1.0,
-		sip_outbound_registration_status_str(status));
-	client_state->status = status;
+		status_new);
 }
 
 /*! \brief Callback function for unregistering (potentially) and destroying state */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If851c7d514bb530d9226e4941ba97dcf52000646
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list