Commit eb499961 authored by Keith Packard's avatar Keith Packard Committed by Mike Gabriel

os: Use NotifyFd for ErrorConnMax

commit c3fea428aed919826130ef8ebdb2cceb445a845b Author: Keith Packard <keithp@keithp.com> Date: Tue May 24 20:51:31 2016 -0700 os: Use NotifyFd for ErrorConnMax Instead of open-coding a single FD wait, use NotifyFd to wait for the FD to become readable before returning the error message. Signed-off-by: 's avatarKeith Packard <keithp@keithp.com> Reviewed-by: 's avatarAdam Jackson <ajax@redhat.com> Backported-to-NX-by: 's avatarMike Gabriel <mike.gabriel@das-netzwerkteam.de>
parent f5301dee
......@@ -74,6 +74,7 @@ SOFTWARE.
#define TRANS_SERVER
#define TRANS_REOPEN
#include <nx-X11/Xtrans/Xtrans.h>
#include <nx-X11/Xtrans/Xtransint.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
......@@ -874,7 +875,6 @@ EstablishNewConnections(ClientPtr clientUnused, void * closure)
))
{
ErrorConnMax(new_trans_conn);
_XSERVTransClose(new_trans_conn);
}
}
#ifndef WIN32
......@@ -891,28 +891,21 @@ EstablishNewConnections(ClientPtr clientUnused, void * closure)
************/
static void
ErrorConnMax(XtransConnInfo trans_conn)
ConnMaxNotify(int fd, int events, void *data)
{
int fd = _XSERVTransGetConnectionNumber (trans_conn);
xConnSetupPrefix csp;
char pad[3];
struct iovec iov[3];
XtransConnInfo trans_conn = data;
char order = 0;
int whichbyte = 1;
struct timeval waittime;
fd_set mask;
/* if these seems like a lot of trouble to go to, it probably is */
waittime.tv_sec = BOTIMEOUT / MILLI_PER_SECOND;
waittime.tv_usec = (BOTIMEOUT % MILLI_PER_SECOND) *
(1000000 / MILLI_PER_SECOND);
FD_ZERO(&mask);
FD_SET(fd, &mask);
(void)Select(fd + 1, &mask, NULL, NULL, &waittime);
/* try to read the byte-order of the connection */
(void)_XSERVTransRead(trans_conn, &order, 1);
if (order == 'l' || order == 'B' || order == 'r' || order == 'R')
{
xConnSetupPrefix csp;
char pad[3] = { 0, 0, 0 };
int whichbyte = 1;
struct iovec iov[3];
csp.success = xFalse;
csp.lengthReason = sizeof(NOROOM) - 1;
csp.length = (sizeof(NOROOM) + 2) >> 2;
......@@ -933,6 +926,15 @@ ErrorConnMax(XtransConnInfo trans_conn)
iov[2].iov_base = pad;
(void)_XSERVTransWritev(trans_conn, iov, 3);
}
RemoveNotifyFd(trans_conn->fd);
_XSERVTransClose(trans_conn);
}
static void
ErrorConnMax(XtransConnInfo trans_conn)
{
if (!SetNotifyFd(trans_conn->fd, ConnMaxNotify, X_NOTIFY_READ, trans_conn))
_XSERVTransClose(trans_conn);
}
/************
......
......@@ -52,7 +52,6 @@ SOFTWARE.
#ifndef _OSDEP_H_
#define _OSDEP_H_ 1
#define BOTIMEOUT 200 /* in milliseconds */
#define BUFSIZE 4096
#define BUFWATERMARK 8192
#ifndef MAXBUFSIZE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment