]> granicus.if.org Git - vim/commitdiff
patch 8.2.4595: X11: using --remote-wait may keep the CPU busy v8.2.4595
authorjsecchiero <secchierojacopo@gmail.com>
Sun, 20 Mar 2022 11:07:17 +0000 (11:07 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 Mar 2022 11:07:17 +0000 (11:07 +0000)
Problem:    X11: using --remote-wait may keep the CPU busy.
Solution:   Set the timeout for select() on every call. (Jacopo Secchiero,
            closes #9973)

src/if_xcmdsrv.c
src/version.c

index 81a4d9de30d23caa68de02276aef2a8284c2ea5d..20427c74846f82bba4cb34947982f4850087e4c9 100644 (file)
@@ -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
        }
index 1cb9ceba4c3a74ddf3b85efa4a9935ab129b39ee..f71228b24d91052c1a16333724eb861b496168c0 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4595,
 /**/
     4594,
 /**/