GHOST/Wayland: fix threaded event handling
The previous fix from T100855 [0] no longer works on my system
(3.4.1 release also fails for GNOME/KDE/WLROOTS compositors).
Resolve by removing the loop from the wait-on-file handle check.
Also reduce locking/unlocking calls.
[0]: 37b256e26f
This commit is contained in:
parent
b599820418
commit
bbe7183cd3
|
@ -1669,24 +1669,24 @@ static int ghost_wl_display_event_pump_from_thread(struct wl_display *wl_display
|
|||
else {
|
||||
wl_display_cancel_read(wl_display);
|
||||
}
|
||||
|
||||
server_mutex->unlock();
|
||||
}
|
||||
else {
|
||||
int state;
|
||||
do {
|
||||
server_mutex->unlock();
|
||||
/* Wait for input (unlocked, so as not to block other threads). */
|
||||
state = file_descriptor_is_io_ready(fd, GWL_IOR_READ | GWL_IOR_NO_RETRY, INT32_MAX);
|
||||
server_mutex->unlock();
|
||||
|
||||
/* Wait for input (unlocked, so as not to block other threads). */
|
||||
int state = file_descriptor_is_io_ready(fd, GWL_IOR_READ | GWL_IOR_NO_RETRY, INT32_MAX);
|
||||
/* Re-check `state` with a lock held, needed to avoid holding the lock. */
|
||||
if (state > 0) {
|
||||
server_mutex->lock();
|
||||
/* Re-check `state` with a lock held, needed to avoid holding the lock. */
|
||||
state = file_descriptor_is_io_ready(fd, GWL_IOR_READ | GWL_IOR_NO_RETRY, 0);
|
||||
if (state > 0) {
|
||||
state = file_descriptor_is_io_ready(fd, GWL_IOR_READ | GWL_IOR_NO_RETRY, 0);
|
||||
if (state > 0) {
|
||||
err = wl_display_dispatch_pending(wl_display);
|
||||
}
|
||||
err = wl_display_dispatch_pending(wl_display);
|
||||
}
|
||||
} while (state > 0);
|
||||
server_mutex->unlock();
|
||||
}
|
||||
}
|
||||
server_mutex->unlock();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue