changeset 28142:7dec326adb36 v8.2.4595

patch 8.2.4595: X11: using --remote-wait may keep the CPU busy Commit: https://github.com/vim/vim/commit/6f953636771fe90e593b1c0ec883c261f6dc1bbb Author: jsecchiero <secchierojacopo@gmail.com> Date: Sun Mar 20 11:07:17 2022 +0000 patch 8.2.4595: X11: using --remote-wait may keep the CPU busy Problem: X11: using --remote-wait may keep the CPU busy. Solution: Set the timeout for select() on every call. (Jacopo Secchiero, closes #9973)
author Bram Moolenaar <Bram@vim.org>
date Sun, 20 Mar 2022 12:15:03 +0100
parents dce918af0c00
children 985f0dd88a2e
files src/if_xcmdsrv.c src/version.c
diffstat 2 files changed, 17 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
+#ifdef HAVE_SELECT
+    fd_set	    fds;
+
+    FD_ZERO(&fds);
+    FD_SET(ConnectionNumber(dpy), &fds);
+#else
     struct pollfd   fds;
 
     fds.fd = ConnectionNumber(dpy);
     fds.events = POLLIN;
-#else
-    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);
 #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
 	}
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4595,
+/**/
     4594,
 /**/
     4593,