feat(startup): validate --listen address

Problem:
`nvim --listen` does not error on EADDRINUSE. #30123

Solution:
Now that `$NVIM_LISTEN_ADDRESS` is deprecated and input *only* (instead
of the old, ambiguous situation where it was both an input *and* an
output), we can be fail fast instead of trying to "recover". This
reverts the "recovery" behavior of
704ba4151e, but that was basically
a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
This commit is contained in:
Justin M. Keyes
2024-09-02 15:57:07 +02:00
parent 137f98cf64
commit 96128a5076
6 changed files with 101 additions and 59 deletions

View File

@@ -332,12 +332,6 @@ int main(int argc, char **argv)
#endif
bool use_builtin_ui = (has_term && !headless_mode && !embedded_mode && !silent_mode);
// don't bind the server yet, if we are using builtin ui.
// This will be done when nvim server has been forked from the ui process
if (!use_builtin_ui) {
server_init(params.listen_addr);
}
if (params.remote) {
remote_request(&params, params.remote, params.server_addr, argc, argv,
use_builtin_ui);
@@ -355,11 +349,19 @@ int main(int argc, char **argv)
ui_client_channel_id = rv;
}
// NORETURN: Start builtin UI client.
if (ui_client_channel_id) {
time_finish();
ui_client_run(remote_ui); // NORETURN
}
assert(!ui_client_channel_id && !use_builtin_ui);
// Nvim server...
int listen_rv = server_init(params.listen_addr);
if (listen_rv != 0) {
mainerr("Failed to --listen", listen_rv < 0
? os_strerror(listen_rv) : (listen_rv == 1 ? "empty address" : NULL));
}
TIME_MSG("expanding arguments");