Reorder a lock to prevent a potential deadlock in uvars

A call to default_vars_path() takes the environment variable
lock while the uvars lock is held. Ensure that doesn't happen by
deferring the uvars lock to later in the function.
This commit is contained in:
ridiculousfish 2017-03-26 13:22:23 -07:00
parent 9f13edbe4a
commit 44b3554a11

View file

@ -505,10 +505,10 @@ bool env_universal_t::move_new_vars_file_into_place(const wcstring &src, const w
}
bool env_universal_t::load() {
scoped_lock locker(lock);
callback_data_list_t callbacks;
const wcstring vars_path =
explicit_vars_path.empty() ? default_vars_path() : explicit_vars_path;
scoped_lock locker(lock);
bool success = load_from_path(vars_path, &callbacks);
if (!success && !tried_renaming && errno == ENOENT) {
// We failed to load, because the file was not found. Older fish used the hostname only. Try