mirror of https://github.com/python/cpython.git
(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.
This commit is contained in:
commit
8108e96bc8
|
@ -86,6 +86,10 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
|
||||||
defaults to 0. *offset* must be a multiple of the PAGESIZE or
|
defaults to 0. *offset* must be a multiple of the PAGESIZE or
|
||||||
ALLOCATIONGRANULARITY.
|
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`::
|
This example shows a simple way of using :class:`mmap`::
|
||||||
|
|
||||||
import mmap
|
import mmap
|
||||||
|
|
|
@ -70,7 +70,7 @@ def setUp(self):
|
||||||
with open(support.TESTFN, "wb+") as f:
|
with open(support.TESTFN, "wb+") as f:
|
||||||
f.seek(_4G)
|
f.seek(_4G)
|
||||||
f.write(b"asdf")
|
f.write(b"asdf")
|
||||||
with open(support.TESTFN, "rb") as f:
|
f.flush()
|
||||||
self.mapping = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
self.mapping = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
|
|
@ -79,6 +79,9 @@ Core and Builtins
|
||||||
Library
|
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 #11858: configparser.ExtendedInterpolation expected lower-case section
|
- Issue #11858: configparser.ExtendedInterpolation expected lower-case section
|
||||||
names.
|
names.
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
|
|
||||||
#ifndef MS_WINDOWS
|
#ifndef MS_WINDOWS
|
||||||
#define UNIX
|
#define UNIX
|
||||||
|
# ifdef __APPLE__
|
||||||
|
# include <fcntl.h>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
|
@ -1122,6 +1125,12 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
|
||||||
"mmap invalid access parameter.");
|
"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 HAVE_FSTAT
|
||||||
# ifdef __VMS
|
# ifdef __VMS
|
||||||
/* on OpenVMS we must ensure that all bytes are written to the file */
|
/* on OpenVMS we must ensure that all bytes are written to the file */
|
||||||
|
|
Loading…
Reference in New Issue