From owner-freebsd-current@FreeBSD.ORG Fri May 8 04:33:37 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 99C98CC4; Fri, 8 May 2015 04:33:37 +0000 (UTC) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A6DB1D88; Fri, 8 May 2015 04:33:37 +0000 (UTC) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 66E041FE023; Fri, 8 May 2015 06:33:35 +0200 (CEST) Message-ID: <554C3CCB.3030809@selasky.org> Date: Fri, 08 May 2015 06:34:19 +0200 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Garrett Cooper , Kevin Oberman CC: FreeBSD Current , Ed Maste , Aleksandr Rybalko Subject: Re: Race VT+X11 on -current References: <554B5D11.3080709@selasky.org> <554BC475.50203@selasky.org> <554BD2A8.70702@selasky.org> In-Reply-To: <554BD2A8.70702@selasky.org> Content-Type: multipart/mixed; boundary="------------080204030301050704060908" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 May 2015 04:33:37 -0000 This is a multi-part message in MIME format. --------------080204030301050704060908 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Hi, I have a fix, attached. I'll just throw this in if nobody objects. Seems like a trivial issue: Prevent switching to NULL or own window in the "vt_proc_window_switch" function. This fixes an issue where X11 keyboard input can appear stuck. The cause of the problem is a duplicate TTY device window switch IOCTL during boot, which leaves the "vt_switch_timer" running, because the current window is already selected. While at it factor out some NULL checks. PR: 200032 Reported by: multiple people MFC after: 1 week --HPS --------------080204030301050704060908 Content-Type: text/x-diff; name="vt.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vt.diff" Index: vt_core.c =================================================================== --- vt_core.c (revision 282504) +++ vt_core.c (working copy) @@ -451,9 +451,22 @@ struct vt_device *vd; int ret; + /* Prevent switching to NULL */ + if (vw == NULL) { + DPRINTF(30, "%s: Cannot switch to NULL.", __func__); + return (EINVAL); + } vd = vw->vw_device; curvw = vd->vd_curwindow; + /* + * Prevent switching to self to avoid starting the + * "vt_switch_timer()" again: + */ + if (vw == curvw) { + DPRINTF(30, "%s: Cannot switch to self.", __func__); + return (0); + } if (curvw->vw_flags & VWF_VTYLOCK) return (EBUSY); @@ -664,8 +677,7 @@ if (console == 0) { if (c >= F_SCR && c <= MIN(L_SCR, F_SCR + VT_MAXWINDOWS - 1)) { vw = vd->vd_windows[c - F_SCR]; - if (vw != NULL) - vt_proc_window_switch(vw); + vt_proc_window_switch(vw); return; } VT_LOCK(vd); @@ -750,8 +762,7 @@ if (c >= F_SCR && c <= MIN(L_SCR, F_SCR + VT_MAXWINDOWS - 1)) { vw = vd->vd_windows[c - F_SCR]; - if (vw != NULL) - vt_proc_window_switch(vw); + vt_proc_window_switch(vw); return (0); } @@ -760,15 +771,13 @@ /* Switch to next VT. */ c = (vw->vw_number + 1) % VT_MAXWINDOWS; vw = vd->vd_windows[c]; - if (vw != NULL) - vt_proc_window_switch(vw); + vt_proc_window_switch(vw); return (0); case PREV: /* Switch to previous VT. */ c = (vw->vw_number - 1) % VT_MAXWINDOWS; vw = vd->vd_windows[c]; - if (vw != NULL) - vt_proc_window_switch(vw); + vt_proc_window_switch(vw); return (0); case SLK: { vt_save_kbd_state(vw, kbd); --------------080204030301050704060908--