changeset 84:81b78a91f2f5

imported patch mmap-fix
author Scott Chacon <schacon@gmail.com>
date Fri, 08 May 2009 11:33:45 -0700
parents f8f975c73ed0
children 8f5fddaf002a
files dulwich/pack.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dulwich/pack.py
+++ b/dulwich/pack.py
@@ -114,9 +114,14 @@
     :param access: Access mechanism.
     :return: MMAP'd area.
     """
-    mem = mmap.mmap(f.fileno(), size+offset, access=access)
-    return mem, offset
-
+    print f, offset, size
+    if supports_mmap_offset:
+        mem = mmap.mmap(f.fileno(), size + offset % mmap.PAGESIZE, access=access,
+                offset=offset / mmap.PAGESIZE * mmap.PAGESIZE)
+        return mem, offset % mmap.PAGESIZE
+    else:
+        mem = mmap.mmap(f.fileno(), size+offset, access=access)
+        return mem, offset
 
 def load_pack_index(filename):
     f = open(filename, 'r')