ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Blob Blame History Raw
From c600022303a10155f48a8eab59c6c0ae1b797699 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 11 Sep 2014 15:28:37 +0200
Subject: [PATCH] terminal: enable sessions in evcat after taking control

If we enable a session, any probed device might get immediately enabled.
This might cause TakeDevice() messages to be sent before we call
TakeControl(). Therefore, enable sessions *after* sending TakeControl() so
we always succeed if TakeControl() succeeds.
---
 src/libsystemd-terminal/evcat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
index 590a30d873..8c27fb2c54 100644
--- a/src/libsystemd-terminal/evcat.c
+++ b/src/libsystemd-terminal/evcat.c
@@ -313,8 +313,6 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
                         return r;
                 }
 
-                idev_session_enable(e->idev_session);
-
                 if (e->managed) {
                         r = sysview_session_take_control(ev->session_add.session);
                         if (r < 0) {
@@ -323,6 +321,8 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
                         }
                 }
 
+                idev_session_enable(e->idev_session);
+
                 break;
         case SYSVIEW_EVENT_SESSION_REMOVE:
                 idev_session_disable(e->idev_session);