summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-01 23:11:33 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-01 23:11:33 (GMT)
commit8108e96bc811eeb61594e398848d25cbe9efbffe (patch)
tree31ca95d076488661f741776f28d7d1b4ebd711c4 /Modules/mmapmodule.c
parentcee01bf18faa9eb95b93c24711cbebbe36d91336 (diff)
parenta6cd0cf0f5530f1e96114927b2824f6dc61f1bbd (diff)
downloadcpython-8108e96bc811eeb61594e398848d25cbe9efbffe.zip
cpython-8108e96bc811eeb61594e398848d25cbe9efbffe.tar.gz
cpython-8108e96bc811eeb61594e398848d25cbe9efbffe.tar.bz2
(Merge 3.1) Issue #11277: mmap.mmap() calls fcntl(fd, F_FULLFSYNC) on Mac OS X
to get around a mmap bug with sparse files. Patch written by Steffen Daode Nurpmeso.
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index fdf3922..36ca67d 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -23,6 +23,9 @@
#ifndef MS_WINDOWS
#define UNIX
+# ifdef __APPLE__
+# include <fcntl.h>
+# endif
#endif
#ifdef MS_WINDOWS
@@ -1122,6 +1125,12 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
"mmap invalid access parameter.");
}
+#ifdef __APPLE__
+ /* Issue #11277: fsync(2) is not enough on OS X - a special, OS X specific
+ fcntl(2) is necessary to force DISKSYNC and get around mmap(2) bug */
+ if (fd != -1)
+ (void)fcntl(fd, F_FULLFSYNC);
+#endif
#ifdef HAVE_FSTAT
# ifdef __VMS
/* on OpenVMS we must ensure that all bytes are written to the file */