Implement server_address_new()

When creating a local socket/pipe (server_start()) Neovim used vim_tempname() to
generate a unique socket path. For Windows UNIX filepaths cannot be used as
pipe names (they must start with \\.\pipe\). This commit replaces the use of
vim_tempname() for server addresses with server_address_new().

server_address_new() generates unique names for local sockets/pipes - for UNIX
it uses vim_tempname(), for Windows generates names in the form

    \\.\pipe\nvim-PID-COUNTER

where PID is the current process id, and COUNTER is a static uint32_t counter
incremented with every call. This function is now used for server_start() and
server_init() when no address is available.
This commit is contained in:
Rui Abreu Ferreira
2015-09-30 16:13:12 +01:00
parent e9de70e4ea
commit 5161f447f6
2 changed files with 24 additions and 2 deletions

View File

@@ -14572,7 +14572,7 @@ static void f_serverstart(typval_T *argvars, typval_T *rettv)
rettv->vval.v_string = vim_strsave(get_tv_string(argvars));
}
} else {
rettv->vval.v_string = vim_tempname();
rettv->vval.v_string = (char_u *)server_address_new();
}
int result = server_start((char *) rettv->vval.v_string);