From 71df8f8622207295e76f92369242fa27ae520d35 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 10 May 2021 15:10:52 -0700 Subject: [PATCH] Do not flock the uvars file on remote filesystems In rare cases this may cause the universal variable file to drop an update, if two happen at the same time and HOME is on an nfs mount. But this is considered better than hanging if nfs is lockless. Fixes #7968. --- src/env_universal_common.cpp | 3 +++ src/path.cpp | 2 ++ src/path.h | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 65a6ca93e..6bcafde4b 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -495,6 +495,9 @@ void env_universal_t::initialize_at_path(callback_data_list_t &callbacks, wcstri } void env_universal_t::initialize(callback_data_list_t &callbacks) { + // Set do_flock to false immediately if the default variable path is on a remote filesystem. + // See #7968. + if (path_get_config_is_remote() == 1) do_flock = false; this->initialize_at_path(callbacks, default_vars_path(), true /* migrate legacy */); } diff --git a/src/path.cpp b/src/path.cpp index 963e81d65..59e2abd6d 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -419,6 +419,8 @@ bool path_get_data(wcstring &path) { int path_get_data_is_remote() { return get_data_directory().is_remote; } +int path_get_config_is_remote() { return get_config_directory().is_remote; } + void path_make_canonical(wcstring &path) { // Ignore trailing slashes, unless it's the first character. size_t len = path.size(); diff --git a/src/path.h b/src/path.h index b856753b3..366c1dbbc 100644 --- a/src/path.h +++ b/src/path.h @@ -33,6 +33,9 @@ bool path_get_data(wcstring &path); /// -1 means unknown, 0 means known local, 1 means known remote. int path_get_data_is_remote(); +/// Like path_get_data_is_remote but for config directory. +int path_get_config_is_remote(); + /// Emit any errors if config directories are missing. /// Use the given environment stack to ensure this only occurs once. class env_stack_t;