[PATCH] xwayland-shm: Fix extremely low MaxClient limit due to running out of file-descriptors.

Tomasz Borowik timon37 at gmail.com
Sun Nov 16 04:44:32 PST 2014


Hi,

I've been using xwayland and very quickly running into "Maximum number
of clients reached".
Patch below, though honestly I don't know what #ifdefs should be
around it, or if there's a better solution.

>From ee31975ac1bd046437ace831acf1884f1becf89f Mon Sep 17 00:00:00 2001
From: timon37 <timon37 at gmail.com>
Date: Sun, 16 Nov 2014 13:35:52 +0100
Subject: [PATCH] xwayland-shm: Fix extremely low MaxClient limit due to
 running out of file-descriptors.

There's a very large number of these temp-files created (~7 per xterm).
If they're below MaxClients they effectively steal room for new client
connections (look at os/connection.c AllocNewConnection).
---
 hw/xwayland/xwayland-shm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/xwayland/xwayland-shm.c b/hw/xwayland/xwayland-shm.c
index 2d0ce3e..6855ab4 100644
--- a/hw/xwayland/xwayland-shm.c
+++ b/hw/xwayland/xwayland-shm.c
@@ -68,7 +68,7 @@ set_cloexec_or_close(int fd)
 static int
 create_tmpfile_cloexec(char *tmpname)
 {
-    int fd;
+    int fd, highfd;

 #ifdef HAVE_MKOSTEMP
     fd = mkostemp(tmpname, O_CLOEXEC);
@@ -81,7 +81,11 @@ create_tmpfile_cloexec(char *tmpname)
         unlink(tmpname);
     }
 #endif
-
+    highfd = fcntl(fd, F_DUPFD_CLOEXEC, MaxClients);
+    if (highfd >= 0) {
+        close(fd);
+        return highfd;
+    }
     return fd;
 }

-- 
2.1.3


More information about the xorg-devel mailing list