|
|
c90517 |
From db7e9f8306716c4338b7de01cb1026d8e1dd8afa Mon Sep 17 00:00:00 2001
|
|
|
c90517 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
c90517 |
Date: Tue, 7 Aug 2018 14:04:44 -0400
|
|
|
c90517 |
Subject: [PATCH 17/48] session-worker: don't switch VTs if we're already on
|
|
|
c90517 |
the right VT
|
|
|
c90517 |
|
|
|
c90517 |
commit 5b5dccbd shows that switching VTs to the same VT isn't
|
|
|
c90517 |
exactly a no-op. In order to prevent unnecessary wakeups, avoid
|
|
|
c90517 |
switching VTs if the worker is already on the correct VT.
|
|
|
c90517 |
---
|
|
|
c90517 |
daemon/gdm-session-worker.c | 22 ++++++++++++++++------
|
|
|
c90517 |
1 file changed, 16 insertions(+), 6 deletions(-)
|
|
|
c90517 |
|
|
|
c90517 |
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
|
|
|
c90517 |
index 0322037e0..fd6470bab 100644
|
|
|
c90517 |
--- a/daemon/gdm-session-worker.c
|
|
|
c90517 |
+++ b/daemon/gdm-session-worker.c
|
|
|
c90517 |
@@ -936,91 +936,101 @@ fix_terminal_vt_mode (GdmSessionWorker *worker,
|
|
|
c90517 |
if (ioctl (tty_fd, KDGETMODE, &kernel_display_mode) < 0) {
|
|
|
c90517 |
g_debug ("GdmSessionWorker: couldn't query kernel display mode: %m");
|
|
|
c90517 |
succeeded = FALSE;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
if (kernel_display_mode == KD_TEXT) {
|
|
|
c90517 |
goto out;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
/* VT is in the anti-social state of VT_AUTO + KD_GRAPHICS,
|
|
|
c90517 |
* fix it.
|
|
|
c90517 |
*/
|
|
|
c90517 |
succeeded = handle_terminal_vt_switches (worker, tty_fd);
|
|
|
c90517 |
mode_fixed = TRUE;
|
|
|
c90517 |
out:
|
|
|
c90517 |
if (!succeeded) {
|
|
|
c90517 |
g_error ("GdmSessionWorker: couldn't set up terminal, aborting...");
|
|
|
c90517 |
return;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmSessionWorker: VT mode did %sneed to be fixed",
|
|
|
c90517 |
mode_fixed? "" : "not ");
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
jump_to_vt (GdmSessionWorker *worker,
|
|
|
c90517 |
int vt_number)
|
|
|
c90517 |
{
|
|
|
c90517 |
int fd;
|
|
|
c90517 |
int active_vt_tty_fd;
|
|
|
c90517 |
+ int active_vt = -1;
|
|
|
c90517 |
+ struct vt_stat vt_state = { 0 };
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmSessionWorker: jumping to VT %d", vt_number);
|
|
|
c90517 |
active_vt_tty_fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);
|
|
|
c90517 |
|
|
|
c90517 |
if (worker->priv->session_tty_fd != -1) {
|
|
|
c90517 |
fd = worker->priv->session_tty_fd;
|
|
|
c90517 |
|
|
|
c90517 |
g_debug ("GdmSessionWorker: first setting graphics mode to prevent flicker");
|
|
|
c90517 |
if (ioctl (fd, KDSETMODE, KD_GRAPHICS) < 0) {
|
|
|
c90517 |
g_debug ("GdmSessionWorker: couldn't set graphics mode: %m");
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
/* It's possible that the current VT was left in a broken
|
|
|
c90517 |
* combination of states (KD_GRAPHICS with VT_AUTO), that
|
|
|
c90517 |
* can't be switched away from. This call makes sure things
|
|
|
c90517 |
* are set in a way that VT_ACTIVATE should work and
|
|
|
c90517 |
* VT_WAITACTIVE shouldn't hang.
|
|
|
c90517 |
*/
|
|
|
c90517 |
fix_terminal_vt_mode (worker, active_vt_tty_fd);
|
|
|
c90517 |
} else {
|
|
|
c90517 |
fd = active_vt_tty_fd;
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
handle_terminal_vt_switches (worker, fd);
|
|
|
c90517 |
|
|
|
c90517 |
- if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) {
|
|
|
c90517 |
- g_debug ("GdmSessionWorker: couldn't initiate jump to VT %d: %m",
|
|
|
c90517 |
- vt_number);
|
|
|
c90517 |
- } else if (ioctl (fd, VT_WAITACTIVE, vt_number) < 0) {
|
|
|
c90517 |
- g_debug ("GdmSessionWorker: couldn't finalize jump to VT %d: %m",
|
|
|
c90517 |
- vt_number);
|
|
|
c90517 |
+ if (ioctl (fd, VT_GETSTATE, &vt_state) <= 0) {
|
|
|
c90517 |
+ g_debug ("GdmSessionWorker: couldn't get current VT: %m");
|
|
|
c90517 |
+ } else {
|
|
|
c90517 |
+ active_vt = vt_state.v_active;
|
|
|
c90517 |
+ }
|
|
|
c90517 |
+
|
|
|
c90517 |
+ if (active_vt != vt_number) {
|
|
|
c90517 |
+ if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) {
|
|
|
c90517 |
+ g_debug ("GdmSessionWorker: couldn't initiate jump to VT %d: %m",
|
|
|
c90517 |
+ vt_number);
|
|
|
c90517 |
+ } else if (ioctl (fd, VT_WAITACTIVE, vt_number) < 0) {
|
|
|
c90517 |
+ g_debug ("GdmSessionWorker: couldn't finalize jump to VT %d: %m",
|
|
|
c90517 |
+ vt_number);
|
|
|
c90517 |
+ }
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
close (active_vt_tty_fd);
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
gdm_session_worker_set_state (GdmSessionWorker *worker,
|
|
|
c90517 |
GdmSessionWorkerState state)
|
|
|
c90517 |
{
|
|
|
c90517 |
if (worker->priv->state == state)
|
|
|
c90517 |
return;
|
|
|
c90517 |
|
|
|
c90517 |
worker->priv->state = state;
|
|
|
c90517 |
g_object_notify (G_OBJECT (worker), "state");
|
|
|
c90517 |
}
|
|
|
c90517 |
|
|
|
c90517 |
static void
|
|
|
c90517 |
gdm_session_worker_uninitialize_pam (GdmSessionWorker *worker,
|
|
|
c90517 |
int status)
|
|
|
c90517 |
{
|
|
|
c90517 |
g_debug ("GdmSessionWorker: uninitializing PAM");
|
|
|
c90517 |
|
|
|
c90517 |
if (worker->priv->pam_handle == NULL)
|
|
|
c90517 |
return;
|
|
|
c90517 |
|
|
|
c90517 |
gdm_session_worker_get_username (worker, NULL);
|
|
|
c90517 |
|
|
|
c90517 |
if (worker->priv->state >= GDM_SESSION_WORKER_STATE_SESSION_OPENED) {
|
|
|
c90517 |
pam_close_session (worker->priv->pam_handle, 0);
|
|
|
c90517 |
gdm_session_auditor_report_logout (worker->priv->auditor);
|
|
|
c90517 |
--
|
|
|
c90517 |
2.26.0
|
|
|
c90517 |
|