]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res/res_pjsip_location: Delete contact_status object when contact is deleted 53/1853/1
authorMatt Jordan <mjordan@digium.com>
Thu, 24 Dec 2015 18:19:51 +0000 (12:19 -0600)
committerMatt Jordan <mjordan@digium.com>
Thu, 24 Dec 2015 18:19:51 +0000 (12:19 -0600)
In 450579e908, a change was made that removed the deletion of the
'contact_status' object when a 'contact' object is deleted in sorcery.
This unfortunately means that the 'contact_status' object persists, even when
something has explicitly removed a contact. The result is that the state of
the contact will not be regenerated if that contact is re-created, and the
stale state will be reported/used for that contact. It also results in
no ContactStatusChanged events being generated for either ARI or AMI.

This patch restores the deletion logic that was removed. Doing so now
results in the expected events being generated again.

Change-Id: I28789a112e845072308b5b34522690e3faf58f07

res/res_pjsip/location.c

index 2908f6f70c85539607f94294e780027fb40af0cc..a34e5cdf361c6c96579ee002adee618845222671 100644 (file)
@@ -322,6 +322,14 @@ int ast_sip_location_update_contact(struct ast_sip_contact *contact)
 
 int ast_sip_location_delete_contact(struct ast_sip_contact *contact)
 {
+       void *contact_status_obj;
+
+       contact_status_obj = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), CONTACT_STATUS, ast_sorcery_object_get_id(contact));
+       if (contact_status_obj) {
+               ast_sorcery_delete(ast_sip_get_sorcery(), contact_status_obj);
+               ao2_ref(contact_status_obj, -1);
+       }
+
        return ast_sorcery_delete(ast_sip_get_sorcery(), contact);
 }