chiark / gitweb /
terminal: enable sessions in evcat after taking control
authorDavid Herrmann <dh.herrmann@gmail.com>
Thu, 11 Sep 2014 13:28:37 +0000 (15:28 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Thu, 11 Sep 2014 13:28:37 +0000 (15:28 +0200)
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

index 590a30d..8c27fb2 100644 (file)
@@ -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);