]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: incorrect qualify statistics after disabling for contact
authorKevin Harwell <kharwell@digium.com>
Thu, 30 Oct 2014 17:16:28 +0000 (17:16 +0000)
committerKevin Harwell <kharwell@digium.com>
Thu, 30 Oct 2014 17:16:28 +0000 (17:16 +0000)
When removing the qualify_frequency from an AoR or a contact the statistics
shown when issuing "pjsip show aors" from the CLI are incorrect. This patch
deletes the contact's status object from sorcery, disassociating it from the
contact, if the qualify_freqency is removed from configuration.

ASTERISK-24462 #close
Reported by: Mark Michelson
Review: https://reviewboard.asterisk.org/r/4116/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@426755 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_pjsip/pjsip_options.c

index 6206900056d2e562ece1a240f2c4c0d424753090..33f717498dd5d84a43d065c1e8f21d608142cf48 100644 (file)
@@ -85,6 +85,19 @@ static struct ast_sip_contact_status *find_or_create_contact_status(const struct
        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.
@@ -470,6 +483,8 @@ static void qualify_and_schedule(struct ast_sip_contact *contact)
                }
 
                schedule_qualify(contact);
+       } else {
+               delete_contact_status(contact);
        }
 }