From 7c861655219773edb2b8a9323dbbd3d74ee8c3df Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Jan 2010 09:29:56 +0000 Subject: *** empty log message *** --- eio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/eio.c b/eio.c index 0f48a71..383c940 100644 --- a/eio.c +++ b/eio.c @@ -921,9 +921,10 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) off_t sbytes; res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); - /* freebsd' sendfile will return 0 when success */ - if (res == 0 && sbytes) - /* maybe only on EAGAIN: as usual, the manpage leaves you guessing */ + /* freebsd' sendfile will return 0 on success */ + /* freebsd 8 documents it as only setting *sbytes on EINTR and EAGAIN, but */ + /* not on e.g. EIO or EPIPE - sounds broken */ + if ((res < 0 && (errno == EAGAIN || errno == EINTR) && sbytes) || res == 0) res = sbytes; } @@ -933,7 +934,8 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) off_t sbytes = count; res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); - if (res == 0 && errno == EAGAIN && sbytes) + /* according to the manpage, sbytes is always valid */ + if (sbytes) res = sbytes; } -- cgit v1.2.3