[Asterisk-code-review] Change in asterisk[13]: pjsip_options: Fix non-qualified contacts showing as unavai...

George Joseph (Code Review) asteriskteam at digium.com
Sat Apr 18 14:02:10 CDT 2015


George Joseph has uploaded a new change for review.

  https://gerrit.asterisk.org/147

Change subject: pjsip_options:  Fix non-qualified contacts showing as unavailable
......................................................................

pjsip_options:  Fix non-qualified contacts showing as unavailable

The "Add qualify_timeout processing and eventing" patch introduced
an issue where contacts that had qualify_frequency set to 0 were
showing Unavailable instead Available.  This patch checks for
qualify_frequency=0 and create an "Available"  contact_status
with a RTT = 0.

Change-Id: Ifcbc01533ce57f0e4e584b89a395326e098b8fe7
---
M res/res_pjsip/pjsip_options.c
1 file changed, 18 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/47/147/1

diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 9c0a137..ed3b824 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -86,19 +86,6 @@
 	return status;
 }
 
-static void delete_contact_status(const struct ast_sip_contact *contact)
-{
-	struct ast_sip_contact_status *status = ast_sorcery_retrieve_by_id(
-		ast_sip_get_sorcery(), CONTACT_STATUS, ast_sorcery_object_get_id(contact));
-
-	if (!status) {
-		return;
-	}
-
-	ast_sorcery_delete(ast_sip_get_sorcery(), status);
-	ao2_ref(status, -1);
-}
-
 /*!
  * \internal
  * \brief Update an ast_sip_contact_status's elements.
@@ -489,6 +476,8 @@
  */
 static void qualify_and_schedule(struct ast_sip_contact *contact)
 {
+	struct ast_sip_contact_status *status;
+
 	unschedule_qualify(contact);
 
 	if (contact->qualify_frequency) {
@@ -499,7 +488,13 @@
 
 		schedule_qualify(contact, contact->qualify_frequency * 1000);
 	} else {
-		delete_contact_status(contact);
+		status = find_or_create_contact_status(contact);
+		status->status = AVAILABLE;
+		status->rtt = 0;
+		if (ast_sorcery_update(ast_sip_get_sorcery(), status)) {
+			ast_log(LOG_ERROR, "Unable to update ast_sip_contact_status for contact %s\n",
+				contact->uri);
+		}
 	}
 }
 
@@ -992,6 +987,7 @@
 static int qualify_and_schedule_cb(void *obj, void *arg, int flags)
 {
 	struct ast_sip_contact *contact = obj;
+	struct ast_sip_contact_status *status;
 	struct ast_sip_aor *aor = arg;
 	int initial_interval;
 	int max_time = ast_sip_get_max_initial_qualify_time();
@@ -1011,6 +1007,14 @@
 
 	if (contact->qualify_frequency) {
 		schedule_qualify(contact, initial_interval);
+	} else {
+		status = find_or_create_contact_status(contact);
+		status->status = AVAILABLE;
+		status->rtt = 0;
+		if (ast_sorcery_update(ast_sip_get_sorcery(), status)) {
+			ast_log(LOG_ERROR, "Unable to update ast_sip_contact_status for contact %s\n",
+				contact->uri);
+		}
 	}
 
 	return 0;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcbc01533ce57f0e4e584b89a395326e098b8fe7
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>



More information about the asterisk-code-review mailing list