Commit 3b56a79f authored by Matthijs Douze's avatar Matthijs Douze

fix mmap error in OSX

parent 3bdc5abe
......@@ -233,19 +233,20 @@ void OnDiskInvertedLists::prefetch_lists (const long *list_nos, int n) const
void OnDiskInvertedLists::do_mmap ()
{
const char *rw_flags = read_only ? "r" : "rw+";
const char *rw_flags = read_only ? "r" : "r+";
int prot = read_only ? PROT_READ : PROT_WRITE | PROT_READ;
FILE *f = fopen (filename.c_str(), rw_flags);
FAISS_THROW_IF_NOT_FMT (f, "could not open %s in mode %s: %s",
filename.c_str(), rw_flags, strerror(errno));
ptr = (uint8_t*)mmap (nullptr, totsize,
uint8_t * ptro = (uint8_t*)mmap (nullptr, totsize,
prot, MAP_SHARED, fileno (f), 0);
FAISS_THROW_IF_NOT_FMT (ptr != MAP_FAILED,
FAISS_THROW_IF_NOT_FMT (ptro != MAP_FAILED,
"could not mmap %s: %s",
filename.c_str(),
strerror(errno));
ptr = ptro;
fclose (f);
}
......@@ -334,6 +335,8 @@ OnDiskInvertedLists::OnDiskInvertedLists (
OnDiskInvertedLists::OnDiskInvertedLists ():
InvertedLists (0, 0),
totsize (0),
ptr (nullptr),
read_only (false),
locks (new LockLevels ()),
pf (new OngoingPrefetch (this))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment