From 23752b3ef889ada7b705c51f478f5817e5caaed3 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 25 Oct 2018 13:13:13 -0400 Subject: [PATCH] os: Establish new connections synchronously not on the work queue This contortion made a bit more sense before we got SetNotifyFd and friends, but now there's no need for it. Signed-off-by: Adam Jackson Reviewed-by: Peter Hutterer --- os/connection.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/os/connection.c b/os/connection.c index de9696ec8..fd4f9c0ed 100644 --- a/os/connection.c +++ b/os/connection.c @@ -133,7 +133,7 @@ static Pid_t ParentProcess; int GrabInProgress = 0; static void -QueueNewConnections(int curconn, int ready, void *data); +EstablishNewConnections(int curconn, int ready, void *data); static void set_poll_client(ClientPtr client); @@ -270,7 +270,7 @@ CreateWellKnownSockets(void) int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]); ListenTransFds[i] = fd; - SetNotifyFd(fd, QueueNewConnections, X_NOTIFY_READ, NULL); + SetNotifyFd(fd, EstablishNewConnections, X_NOTIFY_READ, NULL); if (!_XSERVTransIsLocal(ListenTransConns[i])) DefineSelf (fd); @@ -330,7 +330,8 @@ ResetWellKnownSockets(void) } } for (i = 0; i < ListenTransCount; i++) - SetNotifyFd(ListenTransFds[i], QueueNewConnections, X_NOTIFY_READ, NULL); + SetNotifyFd(ListenTransFds[i], EstablishNewConnections, X_NOTIFY_READ, + NULL); ResetAuthorization(); ResetHosts(display); @@ -638,14 +639,12 @@ AllocNewConnection(XtransConnInfo trans_conn, int fd, CARD32 conn_time) /***************** * EstablishNewConnections * If anyone is waiting on listened sockets, accept them. - * Returns a mask with indices of new clients. Updates AllClients - * and AllSockets. + * Updates AllClients and AllSockets. *****************/ -static Bool -EstablishNewConnections(ClientPtr clientUnused, void *closure) +static void +EstablishNewConnections(int curconn, int ready, void *data) { - int curconn = (int) (intptr_t) closure; int newconn; /* fd of new client */ CARD32 connect_time; int i; @@ -667,10 +666,10 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure) } if ((trans_conn = lookup_trans_conn(curconn)) == NULL) - return TRUE; + return; if ((new_trans_conn = _XSERVTransAccept(trans_conn, &status)) == NULL) - return TRUE; + return; newconn = _XSERVTransGetConnectionNumber(new_trans_conn); @@ -682,13 +681,7 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure) if (!AllocNewConnection(new_trans_conn, newconn, connect_time)) { ErrorConnMax(new_trans_conn); } - return TRUE; -} - -static void -QueueNewConnections(int fd, int ready, void *data) -{ - QueueWorkProc(EstablishNewConnections, NULL, (void *) (intptr_t) fd); + return; } #define NOROOM "Maximum number of clients reached" @@ -1015,7 +1008,7 @@ ListenOnOpenFD(int fd, int noxauth) ListenTransConns[ListenTransCount] = ciptr; ListenTransFds[ListenTransCount] = fd; - SetNotifyFd(fd, QueueNewConnections, X_NOTIFY_READ, NULL); + SetNotifyFd(fd, EstablishNewConnections, X_NOTIFY_READ, NULL); /* Increment the count */ ListenTransCount++;