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.
This commit is contained in:
ridiculousfish 2021-05-10 15:10:52 -07:00
parent ba33b6dcc8
commit 71df8f8622
3 changed files with 8 additions and 0 deletions

View File

@ -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 */);
}

View File

@ -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();

View File

@ -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;