diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-08 21:44:03 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-08 21:44:03 +0000 |
commit | 22b71a9b08c99e73c2d80d95951755237d6fb3f5 (patch) | |
tree | 362b886321f435b3d3edcbeea7beeac4bca1b81c | |
parent | 45e7a4de082a89e71812939e3e23eb4ba73d387d (diff) | |
download | pysendfile-22b71a9b08c99e73c2d80d95951755237d6fb3f5.tar.gz |
fix OSX test_headers failure
-rw-r--r-- | sendfilemodule.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sendfilemodule.c b/sendfilemodule.c index c416020..e5a6644 100644 --- a/sendfilemodule.c +++ b/sendfilemodule.c @@ -79,36 +79,40 @@ _parse_off_t(PyObject* arg, void* addr) } -static int +static Py_ssize_t iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, int cnt, int type) { int i, j; + Py_ssize_t blen, total = 0; + *iov = PyMem_New(struct iovec, cnt); if (*iov == NULL) { PyErr_NoMemory(); - return 0; + return total; } *buf = PyMem_New(Py_buffer, cnt); if (*buf == NULL) { PyMem_Del(*iov); PyErr_NoMemory(); - return 0; + return total; } for (i = 0; i < cnt; i++) { - if (PyObject_GetBuffer(PySequence_GetItem(seq, i), &(*buf)[i], - type) == -1) { + if (PyObject_GetBuffer(PySequence_GetItem(seq, i), + &(*buf)[i], type) == -1) { PyMem_Del(*iov); for (j = 0; j < i; j++) { PyBuffer_Release(&(*buf)[j]); - } + } PyMem_Del(*buf); return 0; } (*iov)[i].iov_base = (*buf)[i].buf; - (*iov)[i].iov_len = (*buf)[i].len; + blen = (*buf)[i].len; + (*iov)[i].iov_len = blen; + total += blen; } - return 1; + return total; } static void @@ -177,7 +181,7 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict) if (sf.trl_cnt > 0 && !(i = iov_setup(&(sf.trailers), &tbuf, trailers, sf.trl_cnt, PyBUF_SIMPLE))) - return NULL; + return NULL; #ifdef __APPLE__ sent += i; #endif |