Commit 45d55f7f authored by Ray Strode's avatar Ray Strode
Browse files

lib: manage pending consolekit calls with cancellable

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
parent 2e4b75cc
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment