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 <ajax@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
		
							parent
							
								
									69d8ea4a49
								
							
						
					
					
						commit
						23752b3ef8
					
				| 
						 | 
					@ -133,7 +133,7 @@ static Pid_t ParentProcess;
 | 
				
			||||||
int GrabInProgress = 0;
 | 
					int GrabInProgress = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
QueueNewConnections(int curconn, int ready, void *data);
 | 
					EstablishNewConnections(int curconn, int ready, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
set_poll_client(ClientPtr client);
 | 
					set_poll_client(ClientPtr client);
 | 
				
			||||||
| 
						 | 
					@ -270,7 +270,7 @@ CreateWellKnownSockets(void)
 | 
				
			||||||
        int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
 | 
					        int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ListenTransFds[i] = fd;
 | 
					        ListenTransFds[i] = fd;
 | 
				
			||||||
        SetNotifyFd(fd, QueueNewConnections, X_NOTIFY_READ, NULL);
 | 
					        SetNotifyFd(fd, EstablishNewConnections, X_NOTIFY_READ, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!_XSERVTransIsLocal(ListenTransConns[i]))
 | 
					        if (!_XSERVTransIsLocal(ListenTransConns[i]))
 | 
				
			||||||
            DefineSelf (fd);
 | 
					            DefineSelf (fd);
 | 
				
			||||||
| 
						 | 
					@ -330,7 +330,8 @@ ResetWellKnownSockets(void)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (i = 0; i < ListenTransCount; i++)
 | 
					    for (i = 0; i < ListenTransCount; i++)
 | 
				
			||||||
        SetNotifyFd(ListenTransFds[i], QueueNewConnections, X_NOTIFY_READ, NULL);
 | 
					        SetNotifyFd(ListenTransFds[i], EstablishNewConnections, X_NOTIFY_READ,
 | 
				
			||||||
 | 
					                    NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ResetAuthorization();
 | 
					    ResetAuthorization();
 | 
				
			||||||
    ResetHosts(display);
 | 
					    ResetHosts(display);
 | 
				
			||||||
| 
						 | 
					@ -638,14 +639,12 @@ AllocNewConnection(XtransConnInfo trans_conn, int fd, CARD32 conn_time)
 | 
				
			||||||
/*****************
 | 
					/*****************
 | 
				
			||||||
 * EstablishNewConnections
 | 
					 * EstablishNewConnections
 | 
				
			||||||
 *    If anyone is waiting on listened sockets, accept them.
 | 
					 *    If anyone is waiting on listened sockets, accept them.
 | 
				
			||||||
 *    Returns a mask with indices of new clients.  Updates AllClients
 | 
					 *    Updates AllClients and AllSockets.
 | 
				
			||||||
 *    and AllSockets.
 | 
					 | 
				
			||||||
 *****************/
 | 
					 *****************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static Bool
 | 
					static void
 | 
				
			||||||
EstablishNewConnections(ClientPtr clientUnused, void *closure)
 | 
					EstablishNewConnections(int curconn, int ready, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int curconn = (int) (intptr_t) closure;
 | 
					 | 
				
			||||||
    int newconn;       /* fd of new client */
 | 
					    int newconn;       /* fd of new client */
 | 
				
			||||||
    CARD32 connect_time;
 | 
					    CARD32 connect_time;
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
| 
						 | 
					@ -667,10 +666,10 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((trans_conn = lookup_trans_conn(curconn)) == NULL)
 | 
					    if ((trans_conn = lookup_trans_conn(curconn)) == NULL)
 | 
				
			||||||
        return TRUE;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((new_trans_conn = _XSERVTransAccept(trans_conn, &status)) == NULL)
 | 
					    if ((new_trans_conn = _XSERVTransAccept(trans_conn, &status)) == NULL)
 | 
				
			||||||
        return TRUE;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    newconn = _XSERVTransGetConnectionNumber(new_trans_conn);
 | 
					    newconn = _XSERVTransGetConnectionNumber(new_trans_conn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -682,13 +681,7 @@ EstablishNewConnections(ClientPtr clientUnused, void *closure)
 | 
				
			||||||
    if (!AllocNewConnection(new_trans_conn, newconn, connect_time)) {
 | 
					    if (!AllocNewConnection(new_trans_conn, newconn, connect_time)) {
 | 
				
			||||||
        ErrorConnMax(new_trans_conn);
 | 
					        ErrorConnMax(new_trans_conn);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return TRUE;
 | 
					    return;
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void
 | 
					 | 
				
			||||||
QueueNewConnections(int fd, int ready, void *data)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    QueueWorkProc(EstablishNewConnections, NULL, (void *) (intptr_t) fd);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define NOROOM "Maximum number of clients reached"
 | 
					#define NOROOM "Maximum number of clients reached"
 | 
				
			||||||
| 
						 | 
					@ -1015,7 +1008,7 @@ ListenOnOpenFD(int fd, int noxauth)
 | 
				
			||||||
    ListenTransConns[ListenTransCount] = ciptr;
 | 
					    ListenTransConns[ListenTransCount] = ciptr;
 | 
				
			||||||
    ListenTransFds[ListenTransCount] = fd;
 | 
					    ListenTransFds[ListenTransCount] = fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SetNotifyFd(fd, QueueNewConnections, X_NOTIFY_READ, NULL);
 | 
					    SetNotifyFd(fd, EstablishNewConnections, X_NOTIFY_READ, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Increment the count */
 | 
					    /* Increment the count */
 | 
				
			||||||
    ListenTransCount++;
 | 
					    ListenTransCount++;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue