Fix some races and screeen clearing in VGLEnd().

The mouse signal SIGUSR2 was not turned off for normal termination and
in some other cases.  Thus mouse signals arriving after the frame
buffer was unmapped always caused fatal traps.  The fatal traps occurred
about 1 time in 5 if the mouse was wiggled while vgl is ending.

The screen switch signal SIGUSR1 was turned off after clearing the
flag that it sets.  Unlike the mouse signal, this signal is handled
synchronously, but VGLEnd() does screen clearing which does the
synchronous handling.  This race is harder to lose.  I think it can
get vgl into deadlocked state (waiting in the screen switch handler
with SIGUSR1 to leave that state already turned off).

Turn off the mouse cursor before clearing the screen in VGLEnd().
Otherwise, clearing is careful to not clear the mouse cursor.  Undrawing
an active mouse cursor uses a lot of state, so is dangerous for abnormal
termination, but so is clearing.  Clearing is slow and is usually not
needed, since the kernel also does it (not quite right).
This commit is contained in:
Bruce Evans 2019-04-24 13:15:56 +00:00
parent aee793eec9
commit 53384ed5ee

View File

@ -73,11 +73,11 @@ struct vt_mode smode;
if (!VGLInitDone)
return;
VGLInitDone = 0;
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
VGLSwitchPending = 0;
VGLAbortPending = 0;
signal(SIGUSR1, SIG_IGN);
VGLMousePointerHide();
if (VGLMem != MAP_FAILED) {
VGLClear(VGLDisplay, 0);