mmap: only use mmap to read revlog persistent nodemap if it is safe stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 03 Jul 2024 12:32:57 +0200
branchstable
changeset 51656 21442f87f7fa
parent 51655 8e24f4f86ba8
child 51657 e10b8388f27b
mmap: only use mmap to read revlog persistent nodemap if it is safe Cf `is_mmap_safe` docstring.
mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py	Wed Jul 03 12:47:08 2024 +0200
+++ b/mercurial/revlogutils/nodemap.py	Wed Jul 03 12:32:57 2024 +0200
@@ -74,7 +74,7 @@
     test_race_hook_1()
     try:
         with revlog.opener(filename) as fd:
-            if use_mmap:
+            if use_mmap and revlog.opener.is_mmap_safe(filename):
                 try:
                     data = util.buffer(util.mmapread(fd, data_length))
                 except ValueError:
@@ -205,7 +205,7 @@
                 fd.seek(target_docket.data_length)
                 fd.write(data)
                 if feed_data:
-                    if use_mmap:
+                    if use_mmap and revlog.opener.is_mmap_safe(datafile):
                         fd.flush()
                         new_data = util.buffer(util.mmapread(fd, new_length))
                     else:
@@ -238,7 +238,7 @@
         with revlog.opener(datafile, b'w+') as fd:
             fd.write(data)
             if feed_data:
-                if use_mmap:
+                if use_mmap and revlog.opener.is_mmap_safe(datafile):
                     fd.flush()
                     new_data = util.buffer(util.mmapread(fd, len(data)))
                 else: