Don't use mmap for history files on OpenBSD

OpenBSD's mmap is famously unsychronized with file IO. In theory fsync
and msync can be used to synchronize but I was unable to get it to work.
Just don't use mmap for history on OpenBSD. This fixes the history merge
tests.
This commit is contained in:
ridiculousfish
2021-09-18 13:40:09 -07:00
parent 881b987934
commit 3ed8a57bc5

View File

@@ -1319,7 +1319,15 @@ struct history_t::impl_wrapper_t {
void history_impl_t::resolve_pending() { this->has_pending_item = false; }
bool history_t::chaos_mode = false;
/* OpenBSD's mmap is not synchronized with other file operations. In particular it appears we may
* write() a file, fsync() it, close it, mmap() it, and call msync(), and we still may not see the
* newly written data. Just don't try mmap here. */
#if defined(__OpenBSD__)
bool history_t::never_mmap = true;
#else
bool history_t::never_mmap = false;
#endif
history_t::history_t(wcstring name) : wrap_(make_unique<impl_wrapper_t>(std::move(name))) {}