aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/os/WaitFor.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-02-09 23:33:44 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-03-17 09:40:37 +0100
commit761d74a6805e1030f2206a50834b36d807e8e107 (patch)
tree4b91038e18db1e3d2ae0a9874291c515a69848ad /nx-X11/programs/Xserver/os/WaitFor.c
parent6307e6fc72f3cd748c9dc0e601a87171131309ea (diff)
downloadnx-libs-761d74a6805e1030f2206a50834b36d807e8e107.tar.gz
nx-libs-761d74a6805e1030f2206a50834b36d807e8e107.tar.bz2
nx-libs-761d74a6805e1030f2206a50834b36d807e8e107.zip
os: Implement support for NotifyFd X_NOTIFY_WRITE and removal of AddEnabledDevices/RemoveEnabledDevices
Backported from X.org: commit be5a513fee6cbf29ef7570e57eb0436d70fbd88c Author: Keith Packard <keithp@keithp.com> Date: Mon Dec 7 15:12:14 2015 -0800 Remove AddEnabledDevice and AddGeneralSocket APIs All uses of these interfaces should instead be using the NotifyFd API instead. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com> commit 4020aacd1fc5b9c63369f011aeb9120af9c55218 Author: Keith Packard <keithp@keithp.com> Date: Wed Nov 11 22:02:03 2015 -0800 os: Implement support for NotifyFd X_NOTIFY_WRITE This adds the ability to be notified when a file descriptor is available for writing. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com> Backported-to-NX-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'nx-X11/programs/Xserver/os/WaitFor.c')
-rw-r--r--nx-X11/programs/Xserver/os/WaitFor.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/nx-X11/programs/Xserver/os/WaitFor.c b/nx-X11/programs/Xserver/os/WaitFor.c
index d94ada1d5..3ac2e1c7e 100644
--- a/nx-X11/programs/Xserver/os/WaitFor.c
+++ b/nx-X11/programs/Xserver/os/WaitFor.c
@@ -188,9 +188,9 @@ WaitForSomething(int *pClientsReady)
int curclient;
int selecterr;
int nready;
- fd_set devicesReadable;
CARD32 now = 0;
Bool someReady = FALSE;
+ Bool someNotifyWriteReady = FALSE;
#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
fprintf(stderr, "WaitForSomething: Got called.\n");
@@ -338,7 +338,7 @@ WaitForSomething(int *pClientsReady)
if (dispatchException)
i = -1;
#endif
- else if (AnyClientsWriteBlocked)
+ else if (AnyWritesPending)
{
#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
if (wt == NULL)
@@ -353,8 +353,9 @@ WaitForSomething(int *pClientsReady)
wt -> tv_sec, wt -> tv_usec);
}
#endif
- XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
- i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
+ XFD_COPYSET(&ClientsWriteBlocked, &LastSelectWriteMask);
+ XFD_ORSET(&LastSelectWriteMask, &NotifyWriteFds, &LastSelectWriteMask);
+ i = Select(MaxClients, &LastSelectMask, &LastSelectWriteMask, NULL, wt);
}
else
{
@@ -489,16 +490,22 @@ WaitForSomething(int *pClientsReady)
}
if (someReady)
XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
- if (AnyClientsWriteBlocked && XFD_ANYSET (&clientsWritable))
- {
- NewOutputPending = TRUE;
- XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
- XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
- if (! XFD_ANYSET(&ClientsWriteBlocked))
- AnyClientsWriteBlocked = FALSE;
+ if (AnyWritesPending) {
+ XFD_ANDSET(&clientsWritable, &LastSelectWriteMask, &ClientsWriteBlocked);
+ if (XFD_ANYSET(&clientsWritable)) {
+ NewOutputPending = TRUE;
+ XFD_ORSET(&OutputPending, &clientsWritable, &OutputPending);
+ XFD_UNSET(&ClientsWriteBlocked, &clientsWritable);
+ if (!XFD_ANYSET(&ClientsWriteBlocked) && NumNotifyWriteFd == 0)
+ AnyWritesPending = FALSE;
+ }
+ if (NumNotifyWriteFd != 0) {
+ XFD_ANDSET(&tmp_set, &LastSelectWriteMask, &NotifyWriteFds);
+ if (XFD_ANYSET(&tmp_set))
+ someNotifyWriteReady = TRUE;
+ }
}
- XFD_ANDSET(&devicesReadable, &LastSelectMask, &EnabledDevices);
XFD_ANDSET(&clientsReadable, &LastSelectMask, &AllClients);
XFD_ANDSET(&tmp_set, &LastSelectMask, &WellKnownConnections);
if (XFD_ANYSET(&tmp_set))
@@ -506,10 +513,10 @@ WaitForSomething(int *pClientsReady)
(void *)&LastSelectMask);
XFD_ANDSET(&tmp_set, &LastSelectMask, &NotifyReadFds);
- if (XFD_ANYSET(&tmp_set))
+ if (XFD_ANYSET(&tmp_set) || someNotifyWriteReady)
HandleNotifyFds();
- if (XFD_ANYSET (&devicesReadable) || XFD_ANYSET (&clientsReadable))
+ if (XFD_ANYSET (&clientsReadable))
break;
#ifdef WIN32
/* Windows keyboard and mouse events are added to the input queue