mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
Don't try locking the history file if mmap returns ENODEV
If we try to memory map the history file, and we get back ENODEV meaning that the underlying device does not support memory mapping, then treat that as a hint that the filesystem is remote and disable history locking.
This commit is contained in:
parent
344b072e82
commit
23941ea9ca
1 changed files with 9 additions and 1 deletions
|
@ -130,7 +130,15 @@ impl HistoryFileContents {
|
|||
let region = if should_mmap() {
|
||||
match MmapRegion::map_file(file.as_raw_fd(), len) {
|
||||
Ok(region) => region,
|
||||
Err(err) if err.raw_os_error() == Some(ENODEV) => map_anon(file, len)?,
|
||||
Err(err) if err.raw_os_error() == Some(ENODEV) => {
|
||||
// Our mmap failed with ENODEV, which means the underlying
|
||||
// filesystem does not support mapping. Treat this as a hint
|
||||
// that the filesystem is remote, and so disable locks for
|
||||
// the history file.
|
||||
super::ABANDONED_LOCKING.store(true);
|
||||
// Create an anonymous mapping and read() the file into it.
|
||||
map_anon(file, len)?
|
||||
}
|
||||
Err(_err) => return None,
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue