]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0516: socketserver: spurious error when servername is taken v9.2.0516
authorFoxe Chen <chen.foxe@gmail.com>
Sat, 23 May 2026 15:55:28 +0000 (15:55 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 23 May 2026 15:55:28 +0000 (15:55 +0000)
Problem:  socketserver: when searching for a free socket path,
          socketserver_get_path() emits an error for each name that is
          already in use (after v9.2.0512).
Solution: Add an "ignore" argument to socketserver_get_path() to
          suppress the error (Foxe Chen).

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/socketserver.c
src/version.c

index 7c4e19b536a9483dc0ad6143ad77b9acab3256d9..bc98ae4e2bbc2c72a3781486a273371f260cc9de 100644 (file)
@@ -63,7 +63,7 @@ static channel_T    *client_channels = NULL;
 
 static void socketserver_cleanup(void);
 static char_u *socketserver_create_path(char_u *name, bool quiet);
-static char_u *socketserver_get_path(char_u *name, bool new, bool quiet, bool *fatal);
+static char_u *socketserver_get_path(char_u *name, bool new, bool quiet, bool ignore, bool *fatal);
 static void socketserver_accept(channel_T *channel);
 static void socketserver_close(channel_T *channel);
 static ss_reply_T *socketserver_add_reply(char_u *sender);
@@ -339,10 +339,10 @@ socketserver_create_path(char_u *name, bool quiet)
        if (buf != NULL)
        {
            vim_snprintf((char *)buf, buflen, "%s%d", name, i);
-           path = socketserver_get_path(buf, true, quiet, &fatal);
+           path = socketserver_get_path(buf, true, quiet, true, &fatal);
        }
        else
-           path = socketserver_get_path(name, true, quiet, &fatal);
+           path = socketserver_get_path(name, true, quiet, true, &fatal);
 
        if (fatal)
            break;
@@ -378,12 +378,20 @@ socketserver_create_path(char_u *name, bool quiet)
  * If "new" is true, then return a path if the name does not exist in the known
  * location.
  *
+ * If "ignore" is true, then don't emit an error message if a suitable path
+ * could not be found.
+ *
  * If "fatal" is not NULL, then it is set to true if error is fatal.
  *
  * Returns path on success and NULL on failure.
  */
     static char_u *
-socketserver_get_path(char_u *name, bool new UNUSED, bool quiet, bool *fatal)
+socketserver_get_path(
+       char_u *name,
+       bool new UNUSED,
+       bool quiet,
+       bool ignore UNUSED,
+       bool *fatal)
 {
 # ifdef MSWIN
     // Only support channel addresses on Windows
@@ -507,7 +515,7 @@ socketserver_get_path(char_u *name, bool new UNUSED, bool quiet, bool *fatal)
     {
        if (!res)
            semsg(_("Failed creating socket directory: %s"), strerror(errno));
-       else
+       else if (!ignore)
            semsg(_(e_invalid_server_id_used_str), name);
     }
     if (!res && fatal != NULL)
@@ -1011,7 +1019,7 @@ socketserver_get_channel(char_u *name, bool quiet, bool *wait)
     }
     else
     {
-       address = socketserver_get_path(name, false, quiet, NULL);
+       address = socketserver_get_path(name, false, quiet, false, NULL);
        if (address == NULL)
            return NULL;
        is_unix = true;
@@ -1324,7 +1332,7 @@ socketserver_read_reply(
        return FAIL;
     }
 
-    actual = socketserver_get_path(client, false, false, NULL);
+    actual = socketserver_get_path(client, false, false, false, NULL);
     if (actual == NULL)
        return FAIL;
 
@@ -1385,7 +1393,7 @@ socketserver_peek_reply(char_u *sender, char_u **str)
        return FAIL;
     }
 
-    actual = socketserver_get_path(sender, false, false, NULL);
+    actual = socketserver_get_path(sender, false, false, false, NULL);
     if (actual == NULL)
        return FAIL;
 
index dd6dc159858340a1b97210cf231c479c4bee2322..92eea5baa28a7c183a9dbec4e26d5f3f351c65ba 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    516,
 /**/
     515,
 /**/