From 6de65dfe8720deffb90d8b1b72f987b804c8a4dd Mon Sep 17 00:00:00 2001 From: IoIxD Date: Fri, 25 Sep 2026 13:02:34 -0700 Subject: [PATCH] show an actual error if we ever run out of FDs (thanks rob pike) --- src/backend/wayland/buffer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/wayland/buffer.c b/src/backend/wayland/buffer.c index dec8564f..a11bc309 100644 --- a/src/backend/wayland/buffer.c +++ b/src/backend/wayland/buffer.c @@ -55,24 +55,28 @@ void MwLLWaylandBackbufferDestroy(struct _MwLLWayland* wayland) { void MwLLWaylandBufferSetup(struct _MwLLWaylandShmBuffer* buffer, MwU32 width, MwU32 height) { int stride = width * 4; - char temp_name[] = "/tmp/milsko-wl-shm-XXXXXX"; - char temp_name_back[] = "/tmp/milsko-wl-shm-back-XXXXXX"; + char temp_name[] = "/tmp/milsko-wl-shm-XXXXXXXX"; + char temp_name_back[] = "/tmp/milsko-wl-shm-back-XXXXXXXX"; buffer->buf_size = width * height * 4; buffer->fd = mkstemp(temp_name); buffer->fd_back = mkstemp(temp_name_back); + if(buffer->fd >= FD_SETSIZE - 1) { + MwDispatchError(-1, "Amount of allocated buffers has reached FD_SETSIZE! Cannot continue.\n"); + return; + } unlink(temp_name); unlink(temp_name_back); if(posix_fallocate(buffer->fd, 0, buffer->buf_size) != 0) { - printf("failure setting up wl_shm: could not fallocate. %s.\n", strerror(errno)); + printf("failure setting up wl_shm (front buf): could not fallocate. %s.\n", strerror(errno)); close(buffer->fd); return; } if(posix_fallocate(buffer->fd_back, 0, buffer->buf_size) != 0) { - printf("failure setting up wl_shm: could not fallocate. %s.\n", strerror(errno)); + printf("failure setting up wl_shm (back buf): could not fallocate. %s.\n", strerror(errno)); close(buffer->fd_back); return; }