shm: Close file descriptors not needed
authorOlivier Fourdan <ofourdan@redhat.com>
Mon, 10 Jan 2022 14:10:07 +0000 (15:10 +0100)
committerPekka Paalanen <pq@iki.fi>
Tue, 5 Apr 2022 10:42:03 +0000 (10:42 +0000)
commit6c424e9d4c92087958928492e2b5635d4d5f2b36
treea0f04195e3233763802ebdd65924020941a4df2f
parent2bcc27ff368bb04a86d1cae3d8e62fc31c4bfa54
shm: Close file descriptors not needed

Commit 5a981ee8 implemented a fallback path for platforms which do not
support mremap() such as FreeBSD.

To do so, the file descriptor for the mmap() is not closed immediately
but instead kept as long as the pool exists.

That induces more file descriptors kept open for longer, which in turn
may cause problems as wl_shm may be using a lot of file descriptors,
especially with Xwayland which can create a lot of pixmaps on behalf of
its X11 clients.

For platforms where mremap() is available, keeping those file
descriptors opened is a bit of a waste and may cause exhaustion of file
descriptors sooner that before commit 5a981ee8.

Only keep the mmap() file descriptor open on platforms which do not
implement mremap()  and close it immediately as before on others.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1283
src/wayland-shm.c