aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-09-02 15:57:07 +0200
committerJustin M. Keyes <justinkz@gmail.com>2024-09-02 22:41:41 +0200
commit96128a5076b7e45fc01163151401a9e2acdff565 (patch)
treeb621a6b44c8f95b3db18274b4e6d0f319cdbd391 /src/nvim/main.c
parent137f98cf6428a55b1b7687c151d8481c1deb9347 (diff)
downloadrneovim-96128a5076b7e45fc01163151401a9e2acdff565.tar.gz
rneovim-96128a5076b7e45fc01163151401a9e2acdff565.tar.bz2
rneovim-96128a5076b7e45fc01163151401a9e2acdff565.zip
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 704ba4151e7f67999510ee0ac19fdabb595d530c, but that was basically a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 6b90a13e1e..a45ee81c81 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -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");