Skip to content

Commit

Permalink
Lock X updates for all systems and lock around X cleanup at exit (#391)
Browse files Browse the repository at this point in the history
* Lock X updates for all systems and lock around X cleanup at exit

All systems which could generate I/O interrupts on the X file descriptor need
to have locking enabled, or there is a high probability that the X library
will deadlock. This requirement may be removed in the future with restructuring
of the way that the interrupt driven I/O is handled.

Ensure that the appropriate XLOCK/XUNLOCK is done around the X window
closing code.

* Also lock X updates when building with CMake.
  • Loading branch information
nbriggs authored Aug 26, 2021
1 parent 934a86f commit e957e33
Show file tree
Hide file tree
Showing 21 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OPTION(MAIKO_DISPLAY_X11 "Use X11 for display." ON)
IF(MAIKO_DISPLAY_X11)
FIND_PACKAGE(X11 REQUIRED)
SET(MAIKO_DISPLAY_X11_DEFINITIONS
"-DXWINDOW"
"-DXWINDOW -DLOCK_X_UPDATES"
)
SET(MAIKO_DISPLAY_X11_LIBRARIES X11::X11)
SET(MAIKO_DISPLAY_X11_SRCS
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-cygwin.x86_64-x
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-darwin.386-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/opt/X11/include -DXWINDOW
XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-darwin.aarch64-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/opt/X11/include -DXWINDOW
XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-darwin.ppc-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/usr/X11/include -DXWINDOW
XFLAGS = -I/usr/X11/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-darwin.x86_64-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/opt/X11/include -DXWINDOW
XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O1 -g
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-init-darwin.386
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/opt/X11/include -DXWINDOW
XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it
OPTFLAGS = -O0 -g
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-init-darwin.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/opt/X11/include -DXWINDOW
XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O0 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-init-darwin.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/opt/X11/include -DXWINDOW
XFLAGS = -I/opt/X11/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O0 -g
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-init-linux.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it
OPTFLAGS = -O0 -g
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-init-sunos5.sparc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o

XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -g for MAKEINIT, as it needs debugging often.
OPTFLAGS = -g3 -O0
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-linux.386-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-linux.aarch64-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o

XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-linux.armv7l-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o

XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-linux.x86_64-x
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-openbsd.x86_64-x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xwinman.o


XFLAGS = -I/usr/X11R6/include -DXWINDOW
XFLAGS = -I/usr/X11R6/include -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-sunos5.386-x
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o

XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-sunos5.i386-x
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o

XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-sunos5.sparc-x
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o

XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g3
Expand Down
2 changes: 1 addition & 1 deletion bin/makefile-sunos5.x86_64-x
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
$(OBJECTDIR)xrdopt.o \
$(OBJECTDIR)xwinman.o

XFLAGS = -DXWINDOW
XFLAGS = -DXWINDOW -DLOCK_X_UPDATES

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2 -g
Expand Down
4 changes: 3 additions & 1 deletion src/xinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ void lisp_Xexit(DspInterface dsp)
{
assert(Lisp_Xinitialized);

#if defined(OS5) && defined(I_SETSIG)
#if defined(I_SETSIG)
ioctl(ConnectionNumber(dsp->display_id), I_SETSIG, 0); /* so no interrupts happen during */
#endif

XLOCK;
XDestroySubwindows(dsp->display_id, dsp->LispWindow);
XDestroyWindow(dsp->display_id, dsp->LispWindow);
XCloseDisplay(dsp->display_id);
XUNLOCK(dsp);

Lisp_Xinitialized = false;
} /* end lisp_Xexit */
Expand Down

0 comments on commit e957e33

Please sign in to comment.