summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index b53aae1..d6d1601 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -124,7 +124,8 @@ mmap_object_dealloc(mmap_object *m_obj)
if (m_obj->fd >= 0)
(void) close(m_obj->fd);
if (m_obj->data!=NULL) {
- msync(m_obj->data, m_obj->size, MS_SYNC);
+ if (m_obj->access != ACCESS_READ && m_obj->access != ACCESS_COPY)
+ msync(m_obj->data, m_obj->size, MS_SYNC);
munmap(m_obj->data, m_obj->size);
}
#endif /* UNIX */
@@ -559,6 +560,10 @@ mmap_flush_method(mmap_object *self, PyObject *args)
PyErr_SetString(PyExc_ValueError, "flush values out of range");
return NULL;
}
+
+ if (self->access == ACCESS_READ || self->access == ACCESS_COPY)
+ return PyLong_FromLong(0);
+
#ifdef MS_WINDOWS
return PyInt_FromLong((long) FlushViewOfFile(self->data+offset, size));
#elif defined(UNIX)