summaryrefslogtreecommitdiff
path: root/src/if_xcmdsrv.c
diff options
context:
space:
mode:
authorjsecchiero <secchierojacopo@gmail.com>2022-03-20 11:07:17 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-20 11:07:17 +0000
commit6f953636771fe90e593b1c0ec883c261f6dc1bbb (patch)
tree03290ee4530cedcf44ef1af5908ec8f96e90546b /src/if_xcmdsrv.c
parent47c532e2bc55e8a48f7f47e1fae1ed30144f2fa1 (diff)
downloadvim-git-6f953636771fe90e593b1c0ec883c261f6dc1bbb.tar.gz
patch 8.2.4595: X11: using --remote-wait may keep the CPU busyv8.2.4595
Problem: X11: using --remote-wait may keep the CPU busy. Solution: Set the timeout for select() on every call. (Jacopo Secchiero, closes #9973)
Diffstat (limited to 'src/if_xcmdsrv.c')
-rw-r--r--src/if_xcmdsrv.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c
index 81a4d9de3..20427c748 100644
--- a/src/if_xcmdsrv.c
+++ b/src/if_xcmdsrv.c
@@ -556,19 +556,16 @@ ServerWait(
#define UI_MSEC_DELAY 53
#define SEND_MSEC_POLL 500
-#ifndef HAVE_SELECT
- struct pollfd fds;
-
- fds.fd = ConnectionNumber(dpy);
- fds.events = POLLIN;
-#else
+#ifdef HAVE_SELECT
fd_set fds;
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = SEND_MSEC_POLL * 1000;
FD_ZERO(&fds);
FD_SET(ConnectionNumber(dpy), &fds);
+#else
+ struct pollfd fds;
+
+ fds.fd = ConnectionNumber(dpy);
+ fds.events = POLLIN;
#endif
time(&start);
@@ -593,11 +590,17 @@ ServerWait(
// Just look out for the answer without calling back into Vim
if (localLoop)
{
-#ifndef HAVE_SELECT
- if (poll(&fds, 1, SEND_MSEC_POLL) < 0)
+#ifdef HAVE_SELECT
+ struct timeval tv;
+
+ // Set the time every call, select() may change it to the remaining
+ // time.
+ tv.tv_sec = 0;
+ tv.tv_usec = SEND_MSEC_POLL * 1000;
+ if (select(FD_SETSIZE, &fds, NULL, NULL, &tv) < 0)
break;
#else
- if (select(FD_SETSIZE, &fds, NULL, NULL, &tv) < 0)
+ if (poll(&fds, 1, SEND_MSEC_POLL) < 0)
break;
#endif
}