From f74b6e1596f7e027b80a51d337cd289ca04e4962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 30 Oct 2013 16:27:16 -0700 Subject: [PATCH] launcher: Make sure we drop drm master before we allow VT switches 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 | 5 +++++ src/weston-launch.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/launcher-util.c b/src/launcher-util.c index 4f77d115c..4ce06c4fb 100644 --- a/src/launcher-util.c +++ b/src/launcher-util.c @@ -185,6 +185,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"); diff --git a/src/weston-launch.c b/src/weston-launch.c index 03a6a4307..d8364c855 100644 --- a/src/weston-launch.c +++ b/src/weston-launch.c @@ -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");