changeset 51656:21442f87f7fa stable

mmap: only use mmap to read revlog persistent nodemap if it is safe Cf `is_mmap_safe` docstring.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 03 Jul 2024 12:32:57 +0200
parents 8e24f4f86ba8
children e10b8388f27b
files mercurial/revlogutils/nodemap.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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: