summaryrefslogtreecommitdiff
path: root/res/res_pjsip_outbound_registration.c
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2016-05-16 14:29:38 -0600
committerGeorge Joseph <gjoseph@digium.com>2016-05-16 20:43:54 -0500
commit3f6ef63099d58d0aa74895156e8038eb44180ea8 (patch)
tree44d83e0d93928c80275d96d28f00b9891db0f3b0 /res/res_pjsip_outbound_registration.c
parentbcb133ce933c9ba8c36a8c20640f79f0d992ac12 (diff)
res_pjsip_outbound_registration: Clean up state when registration is deleted
Nothing was cleaning up the registration state object when ast_sorcery_delete was called on a registration. So, the registration was deleted from sorcery but the state object went right on refreshing the registration (or failing to refresh the registration) with the peer. * Added a 'deleted' observer on registration that removes the state object. ASTERISK-25964 #close Reported-by Matt Jordan Change-Id: I2db792145cdb1f72ebbf57dd9099596dbbf12c23
Diffstat (limited to 'res/res_pjsip_outbound_registration.c')
-rw-r--r--res/res_pjsip_outbound_registration.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 1ae3522d8..6f17b2072 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -1912,6 +1912,26 @@ static const struct ast_sorcery_instance_observer observer_callbacks_registratio
.object_type_loaded = registration_loaded_observer,
};
+static void registration_deleted_observer(const void *obj)
+{
+ const struct sip_outbound_registration *registration = obj;
+ struct ao2_container *states;
+
+ states = ao2_global_obj_ref(current_states);
+ if (!states) {
+ /* Global container has gone. Likely shutting down. */
+ return;
+ }
+
+ ao2_find(states, ast_sorcery_object_get_id(registration), OBJ_UNLINK | OBJ_NODATA | OBJ_SEARCH_KEY);
+
+ ao2_ref(states, -1);
+}
+
+static const struct ast_sorcery_observer registration_observer = {
+ .deleted = registration_deleted_observer,
+};
+
static int unload_module(void)
{
int remaining;
@@ -2011,7 +2031,9 @@ static int load_module(void)
if (ast_sorcery_instance_observer_add(ast_sip_get_sorcery(),
&observer_callbacks_registrations)
|| ast_sorcery_observer_add(ast_sip_get_sorcery(), "auth",
- &observer_callbacks_auth)) {
+ &observer_callbacks_auth)
+ || ast_sorcery_observer_add(ast_sip_get_sorcery(), "registration",
+ &registration_observer)) {
ast_log(LOG_ERROR, "Unable to register observers.\n");
unload_module();
return AST_MODULE_LOAD_FAILURE;