launcher: Make sure we drop drm master before we allow VT switches
authorKristian Høgsberg <krh@bitplanet.net>
Wed, 30 Oct 2013 23:27:16 +0000 (16:27 -0700)
committerKristian Høgsberg <krh@bitplanet.net>
Wed, 30 Oct 2013 23:27:16 +0000 (16:27 -0700)
On shutdown, we can risk having a pending vt switch that we normally
handle in the vt signal handler.  However as we put the vt back in VT_AUTO
mode, the pending VT switch will go through and if we haven't dropped
drm master at that point, we could switch to another display server
without dropping drm master.  That will typically crash the other server,
so let's try to make sure we don't do that.

https://bugs.freedesktop.org/show_bug.cgi?id=70877

src/launcher-util.c
src/weston-launch.c

index a599686..5ccf302 100644 (file)
@@ -202,6 +202,11 @@ weston_launcher_restore(struct weston_launcher *launcher)
        if (ioctl(launcher->tty, KDSETMODE, KD_TEXT))
                weston_log("failed to set KD_TEXT mode on tty: %m\n");
 
+       /* We have to drop master before we switch the VT back in
+        * VT_AUTO, so we don't risk switching to a VT with another
+        * display server, that will then fail to set drm master. */
+       drm_drop_master(launcher->drm_fd);
+
        mode.mode = VT_AUTO;
        if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0)
                weston_log("could not reset vt handling\n");
index 03a6a43..d8364c8 100644 (file)
@@ -407,6 +407,11 @@ quit(struct weston_launch *wl, int status)
        if (ioctl(wl->tty, KDSETMODE, KD_TEXT))
                fprintf(stderr, "failed to set KD_TEXT mode on tty: %m\n");
 
+       /* We have to drop master before we switch the VT back in
+        * VT_AUTO, so we don't risk switching to a VT with another
+        * display server, that will then fail to set drm master. */
+       drmDropMaster(wl->drm_fd);
+
        mode.mode = VT_AUTO;
        if (ioctl(wl->tty, VT_SETMODE, &mode) < 0)
                fprintf(stderr, "could not reset vt handling\n");