Bug 91072

Summary: XWayland:connection fails with "maximum number of clients reached"
Product: xorg Reporter: Olivier Fourdan <fourdan>
Component: Server/GeneralAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=1231475
Whiteboard:
i915 platform: i915 features:

Description Olivier Fourdan 2015-06-23 11:58:00 UTC
The X server code is assuming that one file descriptor is opened per client in os/connection.c , so it limits the number of file descriptors to the number of clients.

Unfortunately Xwayland opens a lot more file descriptors than a regular X server because of those "weston-shared-XXXXXX" anonymous files for sharing buffers.

The number of /extra/ file descriptors opened depends on the client so the actual limit depends on what application is running.

Once the X server (Xwayland) reaches the number of file descriptors opened, it will raise a "Maximum number of clients reached" even if the actual number of clients is a lot less that the expected limit.
Comment 1 Olivier Fourdan 2015-06-23 12:07:57 UTC
Follow-up patch send to the ML for further review/discussion:

http://lists.x.org/archives/xorg-devel/2015-June/046695.html
Comment 2 Chris Wilson 2015-06-23 12:20:13 UTC
Try

diff --git a/hw/xwayland/xwayland-shm.c b/hw/xwayland/xwayland-shm.c
index 2d0ce3e..1022c0d 100644
--- a/hw/xwayland/xwayland-shm.c
+++ b/hw/xwayland/xwayland-shm.c
@@ -82,7 +82,7 @@ create_tmpfile_cloexec(char *tmpname)
     }
 #endif
 
-    return fd;
+    return os_move_fd(fd);
 }
 
 /*

as a shor term fix.
Comment 3 Olivier Fourdan 2015-06-23 13:04:16 UTC
(In reply to Chris Wilson from comment #2)
> Try
> [...]
> -    return fd;
> +    return os_move_fd(fd);

Or right, that's much better, thanks!

> as a shor term fix.

Why just a short term fix? it looks perfectly spot on to me...
Comment 4 Olivier Fourdan 2015-06-23 14:11:35 UTC
BTW, do you mind if I resend a patch as a follow-up to the ML with your solution with you as author and your signed-off-by?
Comment 5 Chris Wilson 2015-06-23 14:20:50 UTC
(In reply to Olivier Fourdan from comment #3)
> (In reply to Chris Wilson from comment #2)
> > Try
> > [...]
> > -    return fd;
> > +    return os_move_fd(fd);
> 
> Or right, that's much better, thanks!
> 
> > as a shor term fix.
> 
> Why just a short term fix? it looks perfectly spot on to me...

I thought you had scenarios requiring more than 256 clients. Certainly seems conceivable that we will run out.

If that works for you send it on with

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

and your Reported-and-tested-by.
Comment 6 Olivier Fourdan 2015-06-23 14:33:36 UTC
(In reply to Chris Wilson from comment #5)
> If that works for you send it on with
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> and your Reported-and-tested-by.

Done here: http://lists.x.org/archives/xorg-devel/2015-June/046722.html

Thanks!
Comment 7 Olivier Fourdan 2015-07-09 11:31:47 UTC
Fix has been merged in git by Keith, closing.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.