[PATCH 1/2] os: Don't limit MaxClients to MAXCLIENTS
Adam Jackson
ajax at redhat.com
Tue Dec 15 11:25:25 PST 2009
... which is sort of a funny thing to say. MaxClients was actually the
maximum file descriptor number to pass to select(); MAXCLIENTS is the
client count limit. Typical servers have quite a few file descriptors
open below MAXCLIENTS that are not clients (input devices, mostly),
which means you end up losing client slots.
Rename MaxClients to MaxFd, to reflect its true nature, and don't clamp it
to MAXCLIENTS.
Signed-off-by: Adam Jackson <ajax at redhat.com>
fixup
---
dix/dispatch.c | 2 +-
include/opaque.h | 1 -
os/WaitFor.c | 4 ++--
os/connection.c | 18 ++++++------------
os/osdep.h | 6 ++++--
5 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 414bd04..ccbbc74 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -365,7 +365,7 @@ Dispatch(void)
nextFreeClientID = 1;
nClients = 0;
- clientReady = xalloc(sizeof(int) * MaxClients);
+ clientReady = xalloc(sizeof(int) * MAXCLIENTS);
if (!clientReady)
return;
diff --git a/include/opaque.h b/include/opaque.h
index b3c7c70..e97aca9 100644
--- a/include/opaque.h
+++ b/include/opaque.h
@@ -35,7 +35,6 @@ from The Open Group.
extern _X_EXPORT char *defaultTextFont;
extern _X_EXPORT char *defaultCursorFont;
-extern _X_EXPORT int MaxClients;
extern _X_EXPORT volatile char isItTimeToYield;
extern _X_EXPORT volatile char dispatchException;
diff --git a/os/WaitFor.c b/os/WaitFor.c
index 7d10183..92f6e4f 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -222,11 +222,11 @@ WaitForSomething(int *pClientsReady)
else if (AnyClientsWriteBlocked)
{
XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
- i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
+ i = Select (MaxFd, &LastSelectMask, &clientsWritable, NULL, wt);
}
else
{
- i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
+ i = Select (MaxFd, &LastSelectMask, NULL, NULL, wt);
}
selecterr = GetErrno();
WakeupHandler(i, (pointer)&LastSelectMask);
diff --git a/os/connection.c b/os/connection.c
index bf16f6a..e3929f1 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -141,7 +141,7 @@ fd_set LastSelectMask; /* mask returned from last select call */
fd_set ClientsWithInput; /* clients with FULL requests in buffer */
fd_set ClientsWriteBlocked; /* clients who cannot receive output */
fd_set OutputPending; /* clients with reply/event data ready to go */
-int MaxClients = 0;
+int MaxFd = 0;
Bool NewOutputPending; /* not yet attempted to write some new output */
Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
@@ -251,7 +251,7 @@ void SetConnectionTranslation(int conn, int client)
void ClearConnectionTranslation(void)
{
#ifndef WIN32
- for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
+ for (i=0; i<MaxFd; i++) ConnectionTranslation[i] = 0;
#else
unsigned i;
for (i = 0; i < 256; i++)
@@ -287,7 +287,7 @@ lookup_trans_conn (int fd)
return (NULL);
}
-/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
+/* Set MaxFd and lastfdesc, and allocate ConnectionTranslation */
void
InitConnectionLimits(void)
@@ -319,16 +319,10 @@ InitConnectionLimits(void)
if (lastfdesc > MAXSELECT)
lastfdesc = MAXSELECT;
- if (lastfdesc > MAXCLIENTS)
- {
- lastfdesc = MAXCLIENTS;
- if (debug_conns)
- ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS);
- }
- MaxClients = lastfdesc;
+ MaxFd = lastfdesc;
#ifdef DEBUG
- ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients);
+ ErrorF("InitConnectionLimits: MaxFd = %d\n", MaxFd);
#endif
InitConnectionTranslation();
@@ -741,7 +735,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
#ifndef WIN32
fd >= lastfdesc
#else
- XFD_SETCOUNT(&AllClients) >= MaxClients
+ XFD_SETCOUNT(&AllClients) >= MaxFd
#endif
)
return NullClient;
diff --git a/os/osdep.h b/os/osdep.h
index 4ebe0e9..930a638 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -89,9 +89,11 @@ SOFTWARE.
#include <X11/Xpoll.h>
+extern int MaxFd;
+
/*
- * MAXSOCKS is used only for initialising MaxClients when no other method
- * like sysconf(_SC_OPEN_MAX) is not supported.
+ * MAXSOCKS is used only for initialising MaxFd when no other method
+ * like sysconf(_SC_OPEN_MAX) is supported.
*/
#if OPEN_MAX <= 256
--
1.6.5.2
More information about the xorg-devel
mailing list