summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2015-07-07 18:19:50 +0200
committerKeith Packard <keithp@keithp.com>2015-08-24 00:00:18 -0700
commitd206c240c0b85c4da44f073d6e9a692afb6b96d2 (patch)
tree31eebed4e7b51c3e83c243046f707982f9c88ae5 /os
parent7ecdfbf0af3547295b245efa754123db65cabb43 (diff)
configurable maximum number of clients
Make the maximum number of clients user configurable, either from the command line or from xorg.conf This patch works by using the MAXCLIENTS (raised to 512) as the maximum allowed number of clients, but allowing the actual limit to be set by the user to a lower value (keeping the default of 256). There is a limit size of 29 bits to be used to store both the client ID and the X resources ID, so by reducing the number of clients allowed to connect to the X server, the user can increase the number of X resources per client or vice-versa. Parts of this patch are based on a similar patch from Adam Jackson <ajax@redhat.com> This now requires at least xproto 7.0.28 Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'os')
-rw-r--r--os/connection.c6
-rw-r--r--os/osdep.h8
-rw-r--r--os/osinit.c3
-rw-r--r--os/utils.c14
4 files changed, 24 insertions, 7 deletions
diff --git a/os/connection.c b/os/connection.c
index c36b125fe..3d33c4170 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -161,9 +161,9 @@ int *ConnectionTranslation = NULL;
*/
#undef MAXSOCKS
-#define MAXSOCKS 500
+#define MAXSOCKS 512
#undef MAXSELECT
-#define MAXSELECT 500
+#define MAXSELECT 512
struct _ct_node {
struct _ct_node *next;
@@ -299,7 +299,7 @@ InitConnectionLimits(void)
if (lastfdesc > MAXCLIENTS) {
lastfdesc = MAXCLIENTS;
if (debug_conns)
- ErrorF("REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
+ ErrorF("REACHED MAXIMUM CLIENTS LIMIT %d\n", LimitClients);
}
MaxClients = lastfdesc;
diff --git a/os/osdep.h b/os/osdep.h
index 77a5b53ab..86263a53e 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -65,7 +65,7 @@ SOFTWARE.
#ifndef OPEN_MAX
#ifdef SVR4
-#define OPEN_MAX 256
+#define OPEN_MAX 512
#else
#include <sys/param.h>
#ifndef OPEN_MAX
@@ -75,7 +75,7 @@ SOFTWARE.
#if !defined(WIN32)
#define OPEN_MAX NOFILES_MAX
#else
-#define OPEN_MAX 256
+#define OPEN_MAX 512
#endif
#endif
#endif
@@ -89,10 +89,10 @@ SOFTWARE.
* like sysconf(_SC_OPEN_MAX) is not supported.
*/
-#if OPEN_MAX <= 256
+#if OPEN_MAX <= 512
#define MAXSOCKS (OPEN_MAX - 1)
#else
-#define MAXSOCKS 256
+#define MAXSOCKS 512
#endif
/* MAXSELECT is the number of fds that select() can handle */
diff --git a/os/osinit.c b/os/osinit.c
index 91e3e068c..ddd3fce26 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -86,6 +86,9 @@ int limitStackSpace = -1;
int limitNoFile = -1;
#endif
+/* The actual user defined max number of clients */
+int LimitClients = LIMITCLIENTS;
+
static OsSigWrapperPtr OsSigWrapper = NULL;
OsSigWrapperPtr
diff --git a/os/utils.c b/os/utils.c
index d09ca79fd..868eb043a 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -557,6 +557,7 @@ UseMsg(void)
#ifdef LOCK_SERVER
ErrorF("-nolock disable the locking mechanism\n");
#endif
+ ErrorF("-maxclients n set maximum number of clients (power of two)\n");
ErrorF("-nolisten string don't listen on protocol\n");
ErrorF("-listen string listen on protocol\n");
ErrorF("-noreset don't reset after last client exists\n");
@@ -861,6 +862,19 @@ ProcessCommandLine(int argc, char *argv[])
nolock = TRUE;
}
#endif
+ else if ( strcmp( argv[i], "-maxclients") == 0)
+ {
+ if (++i < argc) {
+ LimitClients = atoi(argv[i]);
+ if (LimitClients != 64 &&
+ LimitClients != 128 &&
+ LimitClients != 256 &&
+ LimitClients != 512) {
+ FatalError("maxclients must be one of 64, 128, 256 or 512\n");
+ }
+ } else
+ UseMsg();
+ }
else if (strcmp(argv[i], "-nolisten") == 0) {
if (++i < argc) {
if (_XSERVTransNoListen(argv[i]))