[Asterisk-code-review] res pjsip outbound registration: Clean up state when regist... (asterisk[master])
George Joseph
asteriskteam at digium.com
Mon May 16 15:34:44 CDT 2016
George Joseph has uploaded a new change for review.
https://gerrit.asterisk.org/2850
Change subject: res_pjsip_outbound_registration: Clean up state when registration is deleted
......................................................................
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 moves the state object.
ASTERISK-25964 #close
Reported-by Matt Jordan
Change-Id: I2db792145cdb1f72ebbf57dd9099596dbbf12c23
---
M res/res_pjsip_outbound_registration.c
1 file changed, 23 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/50/2850/1
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 815432d..62fe6da 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -1912,6 +1912,26 @@
.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 @@
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",
+ ®istration_observer)) {
ast_log(LOG_ERROR, "Unable to register observers.\n");
unload_module();
return AST_MODULE_LOAD_FAILURE;
--
To view, visit https://gerrit.asterisk.org/2850
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2db792145cdb1f72ebbf57dd9099596dbbf12c23
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <gjoseph at digium.com>
More information about the asterisk-code-review
mailing list