From 4c2267b0a11e25c2c611e5dd34b716321447c54d Mon Sep 17 00:00:00 2001 From: benoitc Date: Wed, 6 Jul 2011 21:30:45 +0200 Subject: [PATCH] fix issue #229, put the rigt order for fdout and fdin. --- gunicorn/http/_sendfile.py | 3 ++- gunicorn/http/wsgi.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gunicorn/http/_sendfile.py b/gunicorn/http/_sendfile.py index ec1a6d42..cacf6264 100644 --- a/gunicorn/http/_sendfile.py +++ b/gunicorn/http/_sendfile.py @@ -18,7 +18,7 @@ except MemoryError: SUPPORTED_PLATFORMS = ( 'darwin', 'freebsd', - 'dragonfly' + 'dragonfly', 'linux2') if sys.version_info < (2, 6) or \ @@ -35,6 +35,7 @@ def sendfile(fdout, fdin, offset, nbytes): ctypes.c_int] _nbytes = ctypes.c_uint64(nbytes) result = _sendfile(fdin, fdout, offset, _nbytes, None, 0) + if result == -1: e = ctypes.get_errno() if e == errno.EAGAIN and _nbytes.value: diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 313a7adf..3cda17be 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -270,9 +270,9 @@ class Response(object): nbytes -= BLKSIZE else: sent = 0 - sent += sendfile(fileno, sockno, offset+sent, nbytes-sent) + sent += sendfile(sockno, fileno, offset+sent, nbytes-sent) while sent != nbytes: - sent += sendfile(fileno, sockno, offset+sent, nbytes-sent) + sent += sendfile(sockno, fileno, offset+sent, nbytes-sent) def write_file(self, respiter): if sendfile is not None and \