Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
a9e84580 tried to fix 79775575 but introduced a condition where another thread could increase in_ifevent
before waiting for the other thread to unlock the display and also prevented other threads from locking / unlocking the display.
This commit tries to implement 79775575 with a simpler approach which hopefully fixes all issues mentioned in #168 (closed).
Note that I only tested this with firefox on my personal machine and it should be made sure that this still fixes the original problems described in !150 (merged).
Merge request reports
Activity
added 1 commit
- de56cb60 - Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
added 1 commit
- 06442bad - Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
added 1 commit
- 26f1dcef - Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
mentioned in issue #170 (closed)
requested review from @ajax
added 1 commit
- 4cffcfd1 - Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
49 49 unsigned long qe_serial = 0; 50 50 int n; /* time through count */ 51 51 52 dpy->in_ifevent++; 53 52 LockDisplay(dpy); 53 #ifdef XTHREADS 54 dpy->ifevent_thread = xthread_self(); 55 #endif 56 dpy->in_ifevent++; All of these commits make
LockDisplay
a no-op if a thread is inside of aX*IfEvent()
functions.
If another thread now calls another function which tries to lock the display it will simply move on without locking the mutex and waiting for the other thread to unlock the display.
Thexthread_self()
tries to only make the lock functions no-op if it's actually the thread inside of X*IfEvent().
240 240 if (lock_hist_loc >= LOCK_HIST_SIZE) 241 241 lock_hist_loc = 0; 242 242 #endif /* XTHREADS_WARN */ 243 xmutex_unlock(dpy->lock->mutex); 243 244 if (dpy->in_ifevent == 0 || dpy->ifevent_thread != xthread_self()) changed this line in version 5 of the diff
Thanks for noticing this. Yes, it should definitely use
xthread_equal()
. There seems to be at least one other place using==
to compare two threads in the existing codebase, which should be addressed as well.https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/locking.c#L518
for (ti = dpy->error_threads; ti; ti = ti->next) if (ti->error_thread == xthread_self()) return;
added 1 commit
- b3353c03 - Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
mentioned in issue #168 (closed)
added 7 commits
-
b3353c03...0c7c4ce8 - 6 commits from branch
xorg/lib:master
- eb1c272a - Fix a9e845 and 797755 Allow X*IfEvent() to reenter libX11
-
b3353c03...0c7c4ce8 - 6 commits from branch