Message62427
mmap.flush returns the result of the call to FlushViewOfFile as an
integer, and does not check for errors. On unix it does check for
errors. The function should return None and raise an exception if an
error occurs...
This bug can lead to data loss...
Here's the current version of that function:
static PyObject *
mmap_flush_method(mmap_object *self, PyObject *args)
{
Py_ssize_t offset = 0;
Py_ssize_t size = self->size;
CHECK_VALID(NULL);
if (!PyArg_ParseTuple(args, "|nn:flush", &offset, &size))
return NULL;
if ((size_t)(offset + size) > self->size) {
PyErr_SetString(PyExc_ValueError, "flush values out of range");
return NULL;
}
#ifdef MS_WINDOWS
return PyInt_FromLong((long) FlushViewOfFile(self->data+offset, size));
#elif defined(UNIX)
/* XXX semantics of return value? */
/* XXX flags for msync? */
if (-1 == msync(self->data + offset, size, MS_SYNC)) {
PyErr_SetFromErrno(mmap_module_error);
return NULL;
}
return PyInt_FromLong(0);
#else
PyErr_SetString(PyExc_ValueError, "flush not supported on this system");
return NULL;
#endif
} |
|
| Date |
User |
Action |
Args |
| 2008-02-15 13:20:04 | schmir | set | spambayes_score: 0.0343559 -> 0.034355856 recipients:
+ schmir |
| 2008-02-15 13:20:03 | schmir | set | spambayes_score: 0.0343559 -> 0.0343559 messageid: <[email protected]> |
| 2008-02-15 13:20:02 | schmir | link | issue2122 messages |
| 2008-02-15 13:20:01 | schmir | create | |
|