aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-03-15 11:42:30 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-03-21 10:58:08 +0100
commiteb49996116fd3beeff66ddf192bfc80e117086d1 (patch)
tree7af0336d9e36714efba3b189425f9d9facfd44b9 /nx-X11/programs/Xserver
parentf5301dee4e400698f5b8ea324686b8daba75152d (diff)
downloadnx-libs-eb49996116fd3beeff66ddf192bfc80e117086d1.tar.gz
nx-libs-eb49996116fd3beeff66ddf192bfc80e117086d1.tar.bz2
nx-libs-eb49996116fd3beeff66ddf192bfc80e117086d1.zip
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: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Backported-to-NX-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/os/connection.c36
-rw-r--r--nx-X11/programs/Xserver/os/osdep.h1
2 files changed, 19 insertions, 18 deletions
diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c
index 172ed6f4c..2fa8ad12d 100644
--- a/nx-X11/programs/Xserver/os/connection.c
+++ b/nx-X11/programs/Xserver/os/connection.c
@@ -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);
}
/************
diff --git a/nx-X11/programs/Xserver/os/osdep.h b/nx-X11/programs/Xserver/os/osdep.h
index fdd8c7174..d3e9d0b33 100644
--- a/nx-X11/programs/Xserver/os/osdep.h
+++ b/nx-X11/programs/Xserver/os/osdep.h
@@ -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