Bugzilla – Bug 136941
Xlib: Maximum number of clients reached
Last modified: 2005-12-07 13:30:56 UTC
od@blackberry:~> xterm Xlib: connection to ":0.0" refused by server Xlib: Maximum number of clients reached xterm Xt error: Can't open display: :0.0 My system has many open connections from X clients, mainly because every w3m starts a separate w3m-imgdisplay process to render pictures to the current window. blackberry:~ # netstat -n | grep X11 | wc -l 248 Having that many client connections is obviously a problem on the client side. It should be possible to reduce the number of client connections when w3m has better handling of sessions. As this is not available (yet?), I wonder if increasing the maximum number of connections would be acceptable: --- programs/Xserver/include/misc.h.orig 2005-12-05 17:01:05.000000000 +0100 +++ programs/Xserver/include/misc.h 2005-12-05 17:02:36.000000000 +0100 @@ -92,7 +92,7 @@ extern unsigned long serverGeneration; #ifndef MAXSCREENS #define MAXSCREENS 16 #endif -#define MAXCLIENTS 256 +#define MAXCLIENTS 512 #define MAXDITS 1 #define MAXEXTENSIONS 128 #define MAXFORMATS 8
This is really biting me. Tentatively increasing severity to major.
# cvs annotate misc.h [...] 3.14 (dawes 14-Aug-98): #define MAXCLIENTS 256 [...] # cvs log misc.h [...] revision 3.14 date: 1998/08/14 13:35:50; author: dawes; state: Exp; lines: +2 -2 fix some build problems change the connection limit stuff [...] # cvs diff -u -r3.13 -r3.14 misc.h [...] @@ -94,7 +94,7 @@ #ifndef MAXSCREENS #define MAXSCREENS 4 #endif -#define MAXCLIENTS 128 +#define MAXCLIENTS 256 #define MAXDITS 1 #define MAXEXTENSIONS 128 #define MAXFORMATS 8
MAXCLIENT = 512 seems to be already prepared. programs/Xserver/include/resource.h [...] /* bits and fields within a resource id */ #define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */ #if MAXCLIENTS == 64 #define RESOURCE_CLIENT_BITS 6 #endif #if MAXCLIENTS == 128 #define RESOURCE_CLIENT_BITS 7 #endif #if MAXCLIENTS == 256 #define RESOURCE_CLIENT_BITS 8 #endif #if MAXCLIENTS == 512 #define RESOURCE_CLIENT_BITS 9 #endif
The additional memory space used in the X-Server does not seem to increase that much. A few arrays of pointers are bigger, and this: typedef struct _ClientResource { ResourcePtr *resources; int elements; int buckets; int hashsize; /* log(2)(buckets) */ XID fakeID; XID endFakeID; XID expectID; } ClientResourceRec; [...] ClientResourceRec clientTable[MAXCLIENTS]; The only point seems to be that the number of available RESOURCE_IDs decreases from about 2 million (2^21) to one million (2^20): #if MAXCLIENTS == 512 #define RESOURCE_CLIENT_BITS 9 #endif /* client field offset */ #define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS) /* resource field */ #define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1) Egbert, what do you think?
A while ago we were asked to increase this number because the broken IBM Java implementation expected to open up bzillions of clients. We strongly encouraged IBM to fix this - and they did. Here w3m seems to be broken - and should be fixed. We would have to review the code in may places if more than 256 clients will actually work without problems lurking in some remote corners. Being that this is really a corner issue and not a popular request I will rather spend my time on other issues. In amy case this warrent a severity of "major'. Also, where is the limit? Is 512 really enough? Maybe you want to explore the issue yourself and roll an Xserver with MAX_CLIENTS set to 512. If you don't see problems we may want to explore the issue further after SLES10.
I can see your points. Thanks for commenting on this. In the meantime I have had some ideas on how to solve the problem in w3m more quickly, including - using one w3mimgdisplay server for all w3ms running on a client for a given user on a given display - use only one w3m and add a feature to switch between sessions/tabbars Aternatively maybe I can build and test an Xserver with 512 clients myself. I cannot spend much time on this either, but I will see what can be done... Thanks again!