Skip to content

Commit 4b367ad

Browse files
committed
fixed deadlock caused by unnecessary wl_display_cancel_read call
1 parent 6c0e87f commit 4b367ad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/video/wayland/SDL_waylandopengles.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
163163

164164
now = SDL_GetTicks();
165165
if (SDL_TICKS_PASSED(now, max_wait)) {
166-
if (!WAYLAND_wl_display_cancel_read) {
166+
/* If wl_display_prepare_read_queue is not called, we must not call wl_display_cancel_read().
167+
Doing so would decrement wl_display->reader_count to -1, causing a deadlock. */
168+
if (!WAYLAND_wl_display_cancel_read || !WAYLAND_wl_display_prepare_read_queue || !data->gles_swap_frame_event_queue) {
167169
break;
168170
}
169171
/* Timeout expired. Cancel the read. */
@@ -172,7 +174,9 @@ int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
172174
}
173175

174176
if (SDL_IOReady(WAYLAND_wl_display_get_fd(display), SDL_IOR_READ, max_wait - now) <= 0) {
175-
if (!WAYLAND_wl_display_cancel_read) {
177+
/* If wl_display_prepare_read_queue is not called, we must not call wl_display_cancel_read().
178+
Doing so would decrement wl_display->reader_count to -1, causing a deadlock. */
179+
if (!WAYLAND_wl_display_cancel_read || !WAYLAND_wl_display_prepare_read_queue || !data->gles_swap_frame_event_queue) {
176180
break;
177181
}
178182
/* Error or timeout expired without any events for us. Cancel the read. */

0 commit comments

Comments
 (0)