shm: reset buffer pool FD when we close it

This fixes an issue where we ended up "double closing" buffer FDs.

In many cases (especially on compositors with SSDs) this was pretty
rare. And even when it did happen, the FD was normally unused, and
thus nothing bad happened.

However, by quickly resizing the window while using CSDs, it was
fairly easy to trigger this. We sometimes ended up closing the
TIOCSWINCH timer FD while thinking it was a buffer FD, but most of the
times we just ended up closing _another_ buffer’s pool FD, leading to
an immediate disconnect by the compositor.
This commit is contained in:
Daniel Eklöf 2021-07-14 20:51:42 +02:00
parent 9658e9cc18
commit 22651ed221
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

1
shm.c
View file

@ -420,6 +420,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
/* We only need to keep the pool FD open if were going to SHM
* scroll it */
close(pool_fd);
ret->fd = -1;
}
return ret;