Author schmir
Recipients schmir
Date 2008-02-15.13:20:01
SpamBayes Score 0.0343559
Marked as misclassified No
Message-id <1203081603.58.0.172093843344.issue2122@psf.upfronthosting.co.za>
In-reply-to
Content
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
}
History
Date User Action Args
2008-02-15 13:20:04schmirsetspambayes_score: 0.0343559 -> 0.0343559
recipients: + schmir
2008-02-15 13:20:03schmirsetspambayes_score: 0.0343559 -> 0.0343559
messageid: <1203081603.58.0.172093843344.issue2122@psf.upfronthosting.co.za>
2008-02-15 13:20:02schmirlinkissue2122 messages
2008-02-15 13:20:01schmircreate