diff options
author | Ray Strode <rstrode@redhat.com> | 2012-05-21 17:13:09 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2012-06-11 11:33:41 -0400 |
commit | 45d55f7f0033a34aa12d0b7007607ae39b929676 (patch) | |
tree | c78d9ade042855d0b33d57f2c4987d8a3edef409 | |
parent | 2e4b75cc1c3bd38462965fbcfb3603a4d0ccdb49 (diff) |
lib: manage pending consolekit calls with cancellable50112
Pending NewSession objects can disappear just as quickly
as they appear in response to ConsoleKit signals. If
we're in the middle of talking to ConsoleKit when an
object disappears and is subsequently freed, then we'll
still try to access it from the reply callback.
This commit cancels any pending messages to the consolekit
daemon, when the session goes away.
https://bugs.freedesktop.org/show_bug.cgi?id=50112
-rw-r--r-- | src/libaccountsservice/act-user-manager.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c index 68b8670..6ca9678 100644 --- a/src/libaccountsservice/act-user-manager.c +++ b/src/libaccountsservice/act-user-manager.c @@ -104,6 +104,7 @@ typedef struct ActUserManagerNewSessionState state; char *id; ConsoleKitSession *proxy; + GCancellable *cancellable; uid_t uid; char *x11_display; } ActUserManagerNewSession; @@ -962,6 +963,13 @@ unload_new_session (ActUserManagerNewSession *new_session) manager = new_session->manager; + if (new_session->cancellable != NULL && + !g_cancellable_is_cancelled (new_session->cancellable)) { + g_cancellable_cancel (new_session->cancellable); + g_object_unref (new_session->cancellable); + new_session->cancellable = NULL; + } + manager->priv->new_sessions = g_slist_remove (manager->priv->new_sessions, new_session); @@ -1017,6 +1025,10 @@ on_get_unix_user_finished (GObject *object, GError *error = NULL; guint uid; + if (new_session->cancellable == NULL || g_cancellable_is_cancelled (new_session->cancellable)) { + return; + } + if (!console_kit_session_call_get_unix_user_finish (proxy, &uid, result, &error)) { if (error != NULL) { g_debug ("Failed to get uid of session '%s': %s", @@ -1076,7 +1088,7 @@ get_uid_for_new_session (ActUserManagerNewSession *new_session) g_assert (new_session->proxy != NULL); console_kit_session_call_get_unix_user (new_session->proxy, - NULL, + new_session->cancellable, on_get_unix_user_finished, new_session); } @@ -1216,6 +1228,10 @@ on_get_x11_display_finished (GObject *object, GError *error = NULL; char *x11_display; + if (new_session->cancellable == NULL || g_cancellable_is_cancelled (new_session->cancellable)) { + return; + } + if (!console_kit_session_call_get_x11_display_finish (proxy, &x11_display, result, &error)) { if (error != NULL) { g_debug ("Failed to get the x11 display of session '%s': %s", @@ -1303,7 +1319,7 @@ get_x11_display_for_new_session (ActUserManagerNewSession *new_session) g_assert (new_session->proxy != NULL); console_kit_session_call_get_x11_display (new_session->proxy, - NULL, + new_session->cancellable, on_get_x11_display_finished, new_session); } @@ -1392,6 +1408,7 @@ load_new_session (ActUserManager *manager, new_session->manager = g_object_ref (manager); new_session->id = g_strdup (session_id); new_session->state = ACT_USER_MANAGER_NEW_SESSION_STATE_UNLOADED + 1; + new_session->cancellable = g_cancellable_new (); manager->priv->new_sessions = g_slist_prepend (manager->priv->new_sessions, new_session); |