]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0832: socketserver: remote commands can be processed in reverse order v9.2.0832
authorHirohito Higashi <h.east.727@gmail.com>
Wed, 22 Jul 2026 18:15:02 +0000 (18:15 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 22 Jul 2026 18:15:02 +0000 (18:15 +0000)
Problem:  When several clients send a command in quick succession, e.g.
          ":drop" from repeated "--remote-tab", the commands can be
          processed in reverse order, so the files open in the wrong
          order.
Solution: The server inserts a newly accepted client at the head of the
          client list, so pending clients are handled newest-first.
          Append the client to the end of the list instead, so they are
          handled in the order they were accepted (Hirohito Higashi).

closes: #20813

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/socketserver.c
src/version.c

index d109a217508e4c4cd9bf90ebd00218701657ff0f..44107bd4a33d27836b0f423b8ac93730073090ec 100644 (file)
@@ -551,11 +551,23 @@ socketserver_accept(channel_T *channel)
     channel->ch_socketserver = true;
     channel->ch_ss_close_cb = socketserver_client_close;
 
-    channel->ch_ss_next = client_channels;
-    channel->ch_ss_prev = NULL;
-    if (client_channels != NULL)
-       client_channels->ch_ss_prev = channel;
-    client_channels = channel;
+    // Append the client, so that commands are processed in the order the
+    // clients were accepted, not reversed.
+    channel->ch_ss_next = NULL;
+    if (client_channels == NULL)
+    {
+       channel->ch_ss_prev = NULL;
+       client_channels = channel;
+    }
+    else
+    {
+       channel_T *last = client_channels;
+
+       while (last->ch_ss_next != NULL)
+           last = last->ch_ss_next;
+       last->ch_ss_next = channel;
+       channel->ch_ss_prev = last;
+    }
 
     // We will read the command from the client later in the input loop.
     ch_log(NULL, "socketserver: accepted new client");
index e15321420a0576f3c69f524098342709bc77123a..6f05376f5b42eda59b44c6475152d039b87d8f6d 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    832,
 /**/
     831,
 /**/