Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146930541
D2480.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D2480.id.diff
View Options
Index: sys/dev/vt/vt_core.c
===================================================================
--- sys/dev/vt/vt_core.c
+++ sys/dev/vt/vt_core.c
@@ -451,12 +451,35 @@
struct vt_device *vd;
int ret;
+ /* Prevent switching to NULL */
+ if (vw == NULL) {
+ DPRINTF(30, "%s: Cannot switch: vw is NULL.", __func__);
+ return (EINVAL);
+ }
vd = vw->vw_device;
curvw = vd->vd_curwindow;
+ /* Check if virtual terminal is locked */
if (curvw->vw_flags & VWF_VTYLOCK)
return (EBUSY);
+ /* Check if switch already in progress */
+ if (curvw->vw_flags & VWF_SWWAIT_REL) {
+ /* Check if switching to same window */
+ if (curvw->vw_switch_to == vw) {
+ DPRINTF(30, "%s: Switch in progress to same vw.", __func__);
+ return (0); /* success */
+ }
+ DPRINTF(30, "%s: Switch in progress to different vw.", __func__);
+ return (EBUSY);
+ }
+
+ /* Avoid switching to already selected window */
+ if (vw == curvw) {
+ DPRINTF(30, "%s: Cannot switch: vw == curvw.", __func__);
+ return (0); /* success */
+ }
+
/* Ask current process permission to switch away. */
if (curvw->vw_smode.mode == VT_PROCESS) {
DPRINTF(30, "%s: VT_PROCESS ", __func__);
@@ -664,8 +687,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 +772,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 +781,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);
@@ -2774,8 +2793,7 @@
if (vt_suspendswitch == 0)
return;
- /* Switch back to saved window */
- if (vd->vd_savedwindow != NULL)
- vt_proc_window_switch(vd->vd_savedwindow);
+ /* Switch back to saved window, if any */
+ vt_proc_window_switch(vd->vd_savedwindow);
vd->vd_savedwindow = NULL;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 7, 9:05 PM (13 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29380930
Default Alt Text
D2480.id.diff (2 KB)
Attached To
Mode
D2480: Race VT+X11 on -current
Attached
Detach File
Event Timeline
Log In to Comment