daemon/dbus: depreceted _disposable_set_keep_in_use().
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Thu, 6 Jun 2013 13:50:46 +0000 (16:50 +0300)
committerJussi Laako <jussi.laako@linux.intel.com>
Fri, 7 Jun 2013 13:36:46 +0000 (16:36 +0300)
src/common/gsignond-disposable.c
src/common/gsignond-disposable.h
src/daemon/dbus/gsignond-dbus-auth-service-adapter.c
src/daemon/dbus/gsignond-dbus-auth-session-adapter.c
src/daemon/dbus/gsignond-dbus-identity-adapter.c

index 9c3f37f..879a1bb 100644 (file)
@@ -29,7 +29,7 @@
 struct _GSignondDisposablePrivate
 {
     guint timeout;       /* timeout in seconds */
-    gint  keep_obj_counter; /* keep object request counter */
+    volatile gint  keep_obj_counter; /* keep object request counter */
     guint timer_id;      /* timer source id */
 };
 
@@ -89,7 +89,7 @@ _get_property (GObject *object,
             g_value_set_int (value, self->priv->timeout);
             break;
         case PROP_AUTO_DISPOSE:
-            g_value_set_boolean (value, (gboolean)!self->priv->keep_obj_counter);
+            g_value_set_boolean (value, gsignond_disposable_get_auto_dispose(self));
             break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -170,7 +170,7 @@ gsignond_disposable_init (GSignondDisposable *self)
 
     self->priv->timer_id = 0;
     self->priv->timeout = 0;
-    self->priv->keep_obj_counter = 0;
+    g_atomic_int_set(&self->priv->keep_obj_counter, 0);
 
     DBG ("INIT");
 }
@@ -209,9 +209,9 @@ _update_timer (GSignondDisposable *self)
                   self,
                   self->priv->keep_obj_counter, 
                   self->priv->timeout);
-    if (self->priv->keep_obj_counter == 0) {
+    if (g_atomic_int_get(&self->priv->keep_obj_counter) == 0) {
         if (self->priv->timeout) {
-            INFO("Setting object timeout to %d", self->priv->timeout);
+            DBG("Setting object timeout to %d", self->priv->timeout);
             self->priv->timer_id = g_timeout_add_seconds (self->priv->timeout,
                                                           _timer_dispose,
                                                           self);
@@ -229,9 +229,9 @@ gsignond_disposable_set_auto_dispose (GSignondDisposable *self,
 {
     g_return_if_fail (self && GSIGNOND_IS_DISPOSABLE (self));
 
-    if (self->priv->keep_obj_counter == 0 && dispose) return;
+    if (g_atomic_int_get(&self->priv->keep_obj_counter) == 0 && dispose) return;
 
-    self->priv->keep_obj_counter += !dispose ? +1 : -1;
+    g_atomic_int_add (&self->priv->keep_obj_counter, !dispose ? +1 : -1);
 
     _update_timer (self);
 }
@@ -250,21 +250,6 @@ gsignond_disposable_set_timeout (GSignondDisposable *self,
 }
 
 void
-gsignond_disposable_set_keep_in_use (GSignondDisposable *self)
-{
-    /* check if need to reset timer */
-    if (self->priv->keep_obj_counter || !self->priv->timeout) return ;
-
-    if (self->priv->timer_id) 
-        g_source_remove (self->priv->timer_id);
-
-    INFO ("Resetting timer for object '%s' (%p).",
-          G_OBJECT_TYPE_NAME (self), self);
-    self->priv->timer_id = g_timeout_add_seconds (self->priv->timeout, 
-                                                  _timer_dispose, self);
-}
-
-void
 gsignond_disposable_delete_later (GSignondDisposable *self)
 {
     if (self->priv->timer_id)
@@ -275,3 +260,10 @@ gsignond_disposable_delete_later (GSignondDisposable *self)
     self->priv->timer_id = g_idle_add (_auto_dispose, self);
 }
 
+gboolean
+gsignond_disposable_get_auto_dispose (GSignondDisposable *self)
+{
+    g_return_val_if_fail (self && GSIGNOND_IS_DISPOSABLE(self), FALSE);
+
+    return g_atomic_int_get(&self->priv->keep_obj_counter) == 0 ;
+}
index 2f15e50..d831a98 100644 (file)
@@ -58,12 +58,12 @@ struct _GSignondDisposableClass
 GType gsignond_disposable_get_type (void) G_GNUC_CONST;
 
 void
-gsignond_disposable_set_keep_in_use (GSignondDisposable *disposable);
-
-void
 gsignond_disposable_set_auto_dispose (GSignondDisposable *disposable,
                                       gboolean dispose);
 
+gboolean
+gsignond_disposable_get_auto_dispose (GSignondDisposable *disposable);
+
 void
 gsignond_disposable_set_timeout (GSignondDisposable *self,
                                  guint timeout);
index 10782e6..8be08f2 100644 (file)
@@ -268,7 +268,6 @@ _on_identity_disposed (gpointer data, GObject *object)
     self->priv->identities = g_list_remove (self->priv->identities, object);
 
     if (g_list_length (self->priv->identities) == 0) {
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
         gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
     }
 }
@@ -287,7 +286,8 @@ _create_and_cache_dbus_identity (GSignondDbusAuthServiceAdapter *self,
                             g_object_ref (connection), identity, app_context, identity_timeout);
 
     /* keep alive till this identity object gets disposed */
-    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+    if (g_list_length (self->priv->identities) == 0)
+        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
 
     self->priv->identities = g_list_append (self->priv->identities, dbus_identity);
     g_object_weak_ref (G_OBJECT (dbus_identity), _on_identity_disposed, self);
@@ -320,6 +320,8 @@ _handle_register_new_identity (GSignondDbusAuthServiceAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_AUTH_SERVICE_ADAPTER(self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     connection = g_dbus_method_invocation_get_connection (invocation);
 #ifdef USE_P2P
     fd = g_socket_get_fd (g_socket_connection_get_socket (G_SOCKET_CONNECTION (g_dbus_connection_get_stream(connection))));
@@ -345,11 +347,11 @@ _handle_register_new_identity (GSignondDbusAuthServiceAdapter *self,
     else {
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
-        
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
     }
     gsignond_security_context_free (sec_context);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+    
     return TRUE;
 }
 
@@ -367,6 +369,8 @@ _handle_get_identity (GSignondDbusAuthServiceAdapter *self,
     int fd = -1;
     GSignondSecurityContext *sec_context = gsignond_security_context_new ();
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     connection = g_dbus_method_invocation_get_connection (invocation);
 #ifdef USE_P2P
     fd = g_socket_get_fd (g_socket_connection_get_socket (G_SOCKET_CONNECTION (g_dbus_connection_get_stream(connection))));
@@ -394,11 +398,11 @@ _handle_get_identity (GSignondDbusAuthServiceAdapter *self,
     else {
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
-
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
     }
     gsignond_security_context_free (sec_context);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+
     return TRUE;
 }
 
@@ -409,7 +413,9 @@ _handle_query_methods (GSignondDbusAuthServiceAdapter   *self,
 {
     const gchar **methods = NULL;
     GError *error = NULL;
-    
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     methods = gsignond_daemon_query_methods (self->priv->auth_service, &error);
 
     if (error) {
@@ -422,7 +428,7 @@ _handle_query_methods (GSignondDbusAuthServiceAdapter   *self,
               methods ? (const gchar * const*)methods : empty_methods);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
 
     return TRUE;
 }
@@ -436,6 +442,8 @@ _handle_query_mechanisms (GSignondDbusAuthServiceAdapter *self,
     const gchar **mechanisms = 0;
     GError *error = NULL;
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     mechanisms = gsignond_daemon_query_mechanisms (self->priv->auth_service, method, &error);
 
     if (mechanisms)
@@ -446,7 +454,8 @@ _handle_query_mechanisms (GSignondDbusAuthServiceAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+
     return TRUE;
 }
 
@@ -471,6 +480,8 @@ _handle_query_identities (GSignondDbusAuthServiceAdapter *self,
     const gchar *sender =  NULL;
     int fd = -1;
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
 #ifdef USE_P2P
     GDBusConnection *connection = NULL;
     connection = g_dbus_method_invocation_get_connection (invocation);
@@ -512,8 +523,8 @@ _handle_query_identities (GSignondDbusAuthServiceAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
-    
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+
     return TRUE;
 }
 
@@ -528,6 +539,7 @@ _handle_clear (GSignondDbusAuthServiceAdapter *self,
     const gchar *sender =  NULL;
     int fd = -1;
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
 #ifdef USE_P2P
     GDBusConnection *connection = NULL;
     connection = g_dbus_method_invocation_get_connection (invocation);
@@ -555,8 +567,8 @@ _handle_clear (GSignondDbusAuthServiceAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
-    
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+
     return TRUE;
 }
 
index 2c8afef..c537118 100644 (file)
@@ -246,6 +246,8 @@ _handle_query_available_mechanisms (GSignondDbusAuthSessionAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_AUTH_SESSION_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     mechanisms = gsignond_auth_session_query_available_mechanisms (
@@ -261,7 +263,8 @@ _handle_query_available_mechanisms (GSignondDbusAuthSessionAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+
     return TRUE;
 }
 
@@ -304,6 +307,7 @@ _emit_state_changed (gint state, const gchar *message, gpointer user_data)
     gsignond_dbus_auth_session_emit_state_changed (
             self->priv->dbus_auth_session, state, message);
 }
+
 static void
 _on_process_done (GSignondSessionData *reply, const GError *error, gpointer user_data)
 {
@@ -340,6 +344,8 @@ _handle_process (GSignondDbusAuthSessionAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_AUTH_SESSION_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     data = (GSignondSessionData *)gsignond_dictionary_new_from_variant ((GVariant *)session_data);
@@ -355,10 +361,7 @@ _handle_process (GSignondDbusAuthSessionAdapter *self,
         
         self->priv->is_process_active = FALSE;
 
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
-    }
-    else {
-        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
     }
 
     gsignond_dictionary_unref (data);
@@ -374,7 +377,9 @@ _handle_cancel (GSignondDbusAuthSessionAdapter *self,
     GError *error = NULL;
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_AUTH_SESSION_ADAPTER (self), FALSE);
-    
+
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     if (gsignond_auth_session_cancel (self->priv->session, self->priv->ctx, &error))
@@ -384,7 +389,7 @@ _handle_cancel (GSignondDbusAuthSessionAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
 
     return TRUE;
 }
index fe92232..9ddbdfc 100644 (file)
@@ -372,6 +372,7 @@ _on_credentials_updated (_IdentityDbusInfo *info, guint32 updated_id, GError *er
 
     _identity_dbus_info_free (info);
 }
+
 static gboolean
 _handle_request_credentials_update (GSignondDbusIdentityAdapter *self,
                                     GDBusMethodInvocation *invocation,
@@ -382,19 +383,20 @@ _handle_request_credentials_update (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
-    
+
     gsignond_identity_request_credentials_update (self->priv->identity, message, self->priv->sec_context, &error);
     if (error) {
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
-        
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
+        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
     }
     else {
         self->priv->credentials_update_handler_id = g_signal_connect_swapped (self->priv->identity,
             "credentials-updated", G_CALLBACK (_on_credentials_updated), self);
-        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
     }
 
     return TRUE;
@@ -410,6 +412,8 @@ _handle_get_info (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
     
     identity_data = gsignond_identity_get_info (self->priv->identity, 
@@ -424,7 +428,7 @@ _handle_get_info (GSignondDbusIdentityAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
 
     return TRUE;
 }
@@ -454,6 +458,8 @@ _handle_get_auth_session (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     session = gsignond_identity_get_auth_session (self->priv->identity, method, self->priv->sec_context, &error);
@@ -463,6 +469,9 @@ _handle_get_auth_session (GSignondDbusIdentityAdapter *self,
         GSignondDbusAuthSessionAdapter *dbus_session = gsignond_dbus_auth_session_adapter_new_with_connection (
             g_object_ref (self->priv->connection), session, self->priv->app_context, timeout);
 
+        if (g_list_length (self->priv->sessions) == 0)
+            gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
         self->priv->sessions = g_list_append (self->priv->sessions, dbus_session);
 
         g_object_weak_ref (G_OBJECT (dbus_session), _on_session_disposed, self);
@@ -470,15 +479,14 @@ _handle_get_auth_session (GSignondDbusIdentityAdapter *self,
         gsignond_dbus_identity_complete_get_auth_session (
             self->priv->dbus_identity, invocation, 
             gsignond_dbus_auth_session_adapter_get_object_path (dbus_session));
-        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE(self), FALSE);
     }
     else {
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
-
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
     }
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE(self), TRUE);
+
     return TRUE;
 }
 
@@ -504,6 +512,8 @@ _on_user_verfied (_IdentityDbusInfo *info, gboolean res, const GError *error, gp
             self->priv->dbus_identity, invocation, res);
     }
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+
     _identity_dbus_info_free (info);
 }
 
@@ -517,6 +527,8 @@ _handle_verify_user (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     gsignond_identity_verify_user (self->priv->identity, params, self->priv->sec_context, &error);
@@ -525,7 +537,7 @@ _handle_verify_user (GSignondDbusIdentityAdapter *self,
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
 
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
+        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
     }
     else {
         _IdentityDbusInfo *info = _identity_dbus_info_new (self, invocation, NULL);
@@ -533,8 +545,6 @@ _handle_verify_user (GSignondDbusIdentityAdapter *self,
         /* FIXME: Do we allow multiple calls at a given point of time */
         self->priv->verify_user_handler_id = g_signal_connect_swapped (self->priv->identity, 
                     "user-verified", G_CALLBACK (_on_user_verfied), (gpointer)info);
-
-        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE(self), FALSE);
     }
 
     return TRUE;
@@ -574,6 +584,8 @@ _handle_verify_secret (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
     
     gsignond_identity_verify_secret (self->priv->identity, secret, self->priv->sec_context, &error);
@@ -581,15 +593,13 @@ _handle_verify_secret (GSignondDbusIdentityAdapter *self,
     if (error) {
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (self));
+        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
     }
     else {
         _IdentityDbusInfo *info = _identity_dbus_info_new (self, invocation, NULL);
 
         self->priv->verify_secret_handler_id = g_signal_connect_swapped (self->priv->identity, 
                 "secret-verified", G_CALLBACK (_on_secret_verfied), (gpointer)info);
-
-        gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE(self), FALSE);
     }
 
     return TRUE;
@@ -604,19 +614,20 @@ _handle_remove (GSignondDbusIdentityAdapter   *self,
  
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     if (!gsignond_identity_remove (self->priv->identity, self->priv->sec_context, &error)) {
         g_dbus_method_invocation_return_gerror (invocation, error);
         g_error_free (error);
-
-        gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
     }
     else {
         gsignond_dbus_identity_complete_remove (self->priv->dbus_identity, invocation);
-
     }
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
+
     return TRUE;
 }
 
@@ -630,6 +641,8 @@ _handle_sign_out (GSignondDbusIdentityAdapter *self,
  
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     res = gsignond_identity_sign_out (self->priv->identity, self->priv->sec_context, &error);
@@ -642,7 +655,7 @@ _handle_sign_out (GSignondDbusIdentityAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
 
     return TRUE;
 }
@@ -658,6 +671,8 @@ _handle_store (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     id = gsignond_identity_store (self->priv->identity, info, self->priv->sec_context, &error);
@@ -669,7 +684,7 @@ _handle_store (GSignondDbusIdentityAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
 
     return TRUE;
 }
@@ -685,6 +700,8 @@ _handle_add_reference (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     id = gsignond_identity_add_reference (self->priv->identity, reference, self->priv->sec_context, &error);
@@ -697,7 +714,7 @@ _handle_add_reference (GSignondDbusIdentityAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
 
     return TRUE;
 }
@@ -713,6 +730,8 @@ _handle_remove_reference (GSignondDbusIdentityAdapter *self,
 
     g_return_val_if_fail (self && GSIGNOND_IS_DBUS_IDENTITY_ADAPTER (self), FALSE);
 
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), FALSE);
+
     PREPARE_SECURITY_CONTEXT (self, invocation);
 
     id = gsignond_identity_remove_reference (self->priv->identity, reference, self->priv->sec_context, &error);
@@ -724,7 +743,7 @@ _handle_remove_reference (GSignondDbusIdentityAdapter *self,
         g_error_free (error);
     }
 
-    gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE(self));
+    gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (self), TRUE);
 
     return TRUE;
 }