[Asterisk-code-review] pjsip options: wrongly applied "UNKNOWN" status (asterisk[15])
Kevin Harwell
asteriskteam at digium.com
Thu Dec 7 18:37:06 CST 2017
Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/7480
Change subject: pjsip_options: wrongly applied "UNKNOWN" status
......................................................................
pjsip_options: wrongly applied "UNKNOWN" status
A couple of places were setting the status to "UNKNOWN" when qualifies were
being disabeled. Instead this should be set to the "CREATED" status that
represents when a contact is given (uri available), but the qualify frequency
is set to zero so we don't know the status.
ASTERISK-27467
Change-Id: Id67509d25df92a72eb3683720ad2a95a27b50c89
---
M include/asterisk/res_pjsip.h
M res/res_pjsip/pjsip_options.c
2 files changed, 12 insertions(+), 20 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/80/7480/1
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 1c71957..7748f4c 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -289,9 +289,13 @@
* \brief Status type for a contact.
*/
enum ast_sip_contact_status_type {
+ /*! Frequency > 0, but no response from remote uri */
UNAVAILABLE,
+ /*! Frequency > 0, and got response from remote uri */
AVAILABLE,
+ /*! Default last status, and when a contact status object is not found */
UNKNOWN,
+ /*! Frequency == 0, has a contact, but don't know status */
CREATED,
REMOVED,
};
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 662166c..396da3e 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -205,24 +205,12 @@
return;
}
- if (is_contact_refresh
- && status->status == CREATED) {
- /*
- * The contact status hasn't been updated since creation
- * and we don't want to re-send a created status.
- */
- if (contact->qualify_frequency
- || status->rtt_start.tv_sec > 0) {
- /* Ignore, the status will change soon. */
- return;
- }
-
- /*
- * Convert to a regular contact status update
- * because the status may never change.
- */
- is_contact_refresh = 0;
- value = UNKNOWN;
+ /*
+ * If the current status is CREATED, and it's a refresh or the given value is
+ * also CREATED then there is nothing to update as nothing needs to change.
+ */
+ if (status->status == CREATED && (is_contact_refresh || status->status == value)) {
+ return;
}
update = ast_sorcery_alloc(ast_sip_get_sorcery(), CONTACT_STATUS,
@@ -595,7 +583,7 @@
schedule_qualify(contact, contact->qualify_frequency * 1000);
} else {
- update_contact_status(contact, UNKNOWN, 0);
+ update_contact_status(contact, CREATED, 0);
}
}
@@ -1127,7 +1115,7 @@
if (contact->qualify_frequency) {
schedule_qualify(contact, initial_interval);
} else {
- update_contact_status(contact, UNKNOWN, 0);
+ update_contact_status(contact, CREATED, 0);
}
}
--
To view, visit https://gerrit.asterisk.org/7480
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id67509d25df92a72eb3683720ad2a95a27b50c89
Gerrit-Change-Number: 7480
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171207/12bda0ac/attachment-0001.html>
More information about the asterisk-code-review
mailing list