The X libraries used to implement X clients (such as Wine)
do not work properly if multiple threads access the same
display concurrently. It is possible to compile the X
libraries to perform their own synchronization (initiated
by calling XInitThreads()
). However,
Wine does not use this approach. Instead Wine performs its
own synchronization using the
wine_tsx11_lock()
/ wine_tsx11_unlock()
functions. This locking protects library access
with a critical section, and also arranges things so that
X libraries compiled without -D_REENTRANT
(eg. with global errno
variable) will
work with Wine.
In the past, all calls to X used to go through a wrapper called
TSX...()
(for "Thread Safe X ...").
While it is still being used in the code, it's inefficient
as the lock is potentially acquired and released unnecessarily.
New code should explicitly acquire the lock.