diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-03 12:36:36 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-03 12:36:36 (GMT) |
commit | 112d48ac17647879fffa5275dd31dca8bfb3223b (patch) | |
tree | 10b6508c48552c43073299a59dc33d492c809373 | |
parent | cfa8483051554b0e300b4b0c4a84c65bd2819cd3 (diff) | |
download | cpython-112d48ac17647879fffa5275dd31dca8bfb3223b.zip cpython-112d48ac17647879fffa5275dd31dca8bfb3223b.tar.gz cpython-112d48ac17647879fffa5275dd31dca8bfb3223b.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.
-rw-r--r-- | Doc/library/mmap.rst | 4 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/mmapmodule.c | 9 |
3 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst index 125b34f..f036a60 100644 --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -94,6 +94,10 @@ memory but does not update the underlying file. defaults to 0. *offset* must be a multiple of the PAGESIZE or ALLOCATIONGRANULARITY. + To ensure validity of the created memory mapping the file specified + by the descriptor *fileno* is internally automatically synchronized + with physical backing store on Mac OS X and OpenVMS. + This example shows a simple way of using :class:`mmap`:: import mmap @@ -70,6 +70,9 @@ Core and Builtins Library ------- +- 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. + - Issue #10761: Fix tarfile.extractall failure when symlinked files are present. Initial patch by Scott Leerssen. diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index e93acda..3078279 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 @@ -1170,6 +1173,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 */ |