summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2012-01-04 01:19:46 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2012-01-04 01:19:46 +0000
commit6b942b049b0dff411846199f3b3e94e9fc2d7ea2 (patch)
tree3ba10167eac1b9164f3cc8c9d1d1f22b2fa66a7e
parent160ffc5e4cce98df93fa780fbab98b412dff37e3 (diff)
downloadpysendfile-6b942b049b0dff411846199f3b3e94e9fc2d7ea2.tar.gz
BSD systems: do not raise exception if errno == EBUSY and some data has been sent; instead, return the bytes just being sent
-rw-r--r--sendfilemodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sendfilemodule.c b/sendfilemodule.c
index 7a2721b..c6efd02 100644
--- a/sendfilemodule.c
+++ b/sendfilemodule.c
@@ -133,14 +133,15 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict)
}
if (ret < 0) {
- if ((errno == EAGAIN) || (errno == EBUSY)) {
+ if ((errno == EAGAIN) || (errno == EBUSY) || (errno == EWOULDBLOCK)) {
if (sent != 0) {
// some data has been sent
+ errno = 0;
goto done;
}
else {
// no data has been sent; upper application is supposed
- // to retry on EAGAIN or EBUSY
+ // to retry on EAGAIN / EBUSY / EWOULDBLOCK
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}