From 6f179126c72aa2f000058287786e27239f952446 Mon Sep 17 00:00:00 2001 From: Kostia Balytskyi Date: Fri, 9 Feb 2018 13:22:22 -0800 Subject: [PATCH] hg: on Windows, use mmap with explicit ACCESS_READ argument passed Summary: On Windows, the intended access to the file handle must align with the intended access to the memory mapping object, see [1]. When called without and argument, Python's `mmap.mmap` on Windows assumes `ACCESS_WRITE` mode[3], therefore we get failures like [2] in Lego Windows. [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa366537(v=vs.85).aspx [2] P59034213 [3] https://docs.python.org/2/library/mmap.html Reviewed By: quark-zju Differential Revision: D6952583 fbshipit-source-id: 93159f8282e27d3e62d859f4c220e7c3bdfbe958 --- hgext/remotefilelog/basepack.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hgext/remotefilelog/basepack.py b/hgext/remotefilelog/basepack.py index adf0c023c6..f627bcf4af 100644 --- a/hgext/remotefilelog/basepack.py +++ b/hgext/remotefilelog/basepack.py @@ -338,9 +338,11 @@ class basepack(versionmixin): # TODO: use an opener/vfs to access these paths with util.posixfile(self.indexpath, PACKOPENMODE) as indexfp: # memory-map the file, size 0 means whole file - self._index = litemmap.mmap(indexfp.fileno(), 0) + self._index = litemmap.mmap(indexfp.fileno(), 0, + access=litemmap.pymmap.ACCESS_READ) with util.posixfile(self.packpath, PACKOPENMODE) as datafp: - self._data = litemmap.mmap(datafp.fileno(), 0) + self._data = litemmap.mmap(datafp.fileno(), 0, + access=litemmap.pymmap.ACCESS_READ) self._pagedin = 0 return True