summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-05-17 09:57:25 -0700
committerAdam Jackson <ajax@redhat.com>2017-06-13 09:56:31 -0400
commit5d941ccb0b30399d505b48bff894c95cc3023bbe (patch)
treeac5b456a7d2c0d4ba38d7572e485ef8ac5e30048 /os
parentc86fc56b10b603b41ae37057eedfa9c86b609752 (diff)
os: Eliminate ConnectionTranslation
This infrastructure is no longer read, only written; the mapping from fd to client is now handled by ospoll. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'os')
-rw-r--r--os/connection.c127
-rw-r--r--os/osdep.h14
2 files changed, 1 insertions, 140 deletions
diff --git a/os/connection.c b/os/connection.c
index 62e298072..66cb61070 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -142,96 +142,6 @@ set_poll_client(ClientPtr client);
static void
set_poll_clients(void);
-#if !defined(WIN32)
-int *ConnectionTranslation = NULL;
-int ConnectionTranslationSize = 0;
-#else
-/*
- * On NT fds are not small integers, they are unrelated, and there is
- * not even a known maximum value, so use something quite arbitrary for now.
- * Do storage is a hash table of size 256. Collisions are handled in a linked
- * list.
- */
-
-struct _ct_node {
- struct _ct_node *next;
- int key;
- int value;
-};
-
-struct _ct_node *ct_head[256];
-
-void
-InitConnectionTranslation(void)
-{
- memset(ct_head, 0, sizeof(ct_head));
-}
-
-int
-GetConnectionTranslation(int conn)
-{
- struct _ct_node *node = ct_head[conn & 0xff];
-
- while (node != NULL) {
- if (node->key == conn)
- return node->value;
- node = node->next;
- }
- return 0;
-}
-
-void
-SetConnectionTranslation(int conn, int client)
-{
- struct _ct_node **node = ct_head + (conn & 0xff);
-
- if (client == 0) { /* remove entry */
- while (*node != NULL) {
- if ((*node)->key == conn) {
- struct _ct_node *temp = *node;
-
- *node = (*node)->next;
- free(temp);
- return;
- }
- node = &((*node)->next);
- }
- return;
- }
- else {
- while (*node != NULL) {
- if ((*node)->key == conn) {
- (*node)->value = client;
- return;
- }
- node = &((*node)->next);
- }
- *node = malloc(sizeof(struct _ct_node));
- (*node)->next = NULL;
- (*node)->key = conn;
- (*node)->value = client;
- return;
- }
-}
-
-void
-ClearConnectionTranslation(void)
-{
- unsigned i;
-
- for (i = 0; i < 256; i++) {
- struct _ct_node *node = ct_head[i];
-
- while (node != NULL) {
- struct _ct_node *temp = node;
-
- node = node->next;
- free(temp);
- }
- }
-}
-#endif
-
static XtransConnInfo *ListenTransConns = NULL;
static int *ListenTransFds = NULL;
static int ListenTransCount;
@@ -252,7 +162,7 @@ lookup_trans_conn(int fd)
return NULL;
}
-/* Set MaxClients and lastfdesc, and allocate ConnectionTranslation */
+/* Set MaxClients */
void
InitConnectionLimits(void)
@@ -262,15 +172,6 @@ InitConnectionLimits(void)
#ifdef DEBUG
ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients);
#endif
-
-#if !defined(WIN32)
- if (!ConnectionTranslation) {
- ConnectionTranslation = xnfallocarray(MaxClients, sizeof(int));
- ConnectionTranslationSize = MaxClients;
- }
-#else
- InitConnectionTranslation();
-#endif
}
/*
@@ -345,13 +246,6 @@ CreateWellKnownSockets(void)
int i;
int partial;
-#if !defined(WIN32)
- for (i = 0; i < ConnectionTranslationSize; i++)
- ConnectionTranslation[i] = 0;
-#else
- ClearConnectionTranslation();
-#endif
-
/* display is initialized to "0" by main(). It is then set to the display
* number if specified on the command line. */
@@ -737,15 +631,6 @@ AllocNewConnection(XtransConnInfo trans_conn, int fd, CARD32 conn_time)
return NullClient;
}
client->local = ComputeLocalClient(client);
-#if !defined(WIN32)
- if (fd >= ConnectionTranslationSize) {
- ConnectionTranslationSize *= 2;
- ConnectionTranslation = xnfreallocarray(ConnectionTranslation, ConnectionTranslationSize, sizeof (int));
- }
- ConnectionTranslation[fd] = client->index;
-#else
- SetConnectionTranslation(fd, client->index);
-#endif
ospoll_add(server_poll, fd,
ospoll_trigger_edge,
ClientReady,
@@ -781,7 +666,6 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure)
OsCommPtr oc;
XtransConnInfo trans_conn, new_trans_conn;
int status;
- int clientid;
connect_time = GetTimeInMillis();
/* kill off stragglers */
@@ -803,10 +687,6 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure)
newconn = _XSERVTransGetConnectionNumber(new_trans_conn);
- clientid = GetConnectionTranslation(newconn);
- if (clientid && (client = clients[clientid]))
- CloseDownClient(client);
-
_XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
if (trans_conn->flags & TRANS_NOXAUTH)
@@ -889,11 +769,6 @@ CloseDownFileDescriptor(OsCommPtr oc)
_XSERVTransDisconnect(oc->trans_conn);
_XSERVTransClose(oc->trans_conn);
}
-#ifndef WIN32
- ConnectionTranslation[connection] = 0;
-#else
- SetConnectionTranslation(connection, 0);
-#endif
ospoll_remove(server_poll, connection);
}
diff --git a/os/osdep.h b/os/osdep.h
index c5bec3f56..c98b9a2a6 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -141,20 +141,6 @@ extern struct ospoll *server_poll;
Bool
listen_to_client(ClientPtr client);
-#if !defined(WIN32) || defined(__CYGWIN__)
-extern int *ConnectionTranslation;
-extern int ConnectionTranslationSize;
-static inline int GetConnectionTranslation(int conn) {
- if (conn >= ConnectionTranslationSize)
- return 0;
- return ConnectionTranslation[conn];
-}
-#else
-extern int GetConnectionTranslation(int conn);
-extern void SetConnectionTranslation(int conn, int client);
-extern void ClearConnectionTranslation(void);
-#endif
-
extern Bool NewOutputPending;
extern WorkQueuePtr workQueue;