summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2010-01-07 17:18:08 +0000
committerroot <root>2010-01-07 17:18:08 +0000
commitf729dd40abcc81fdd8d940a156fec32c9ca8e4d1 (patch)
tree30f6fd929c184daa88b27720653c46bd27d862b4
parentdc38ef7a470a68fb46d7e43d950e6c7cc4d55006 (diff)
*** empty log message ***
-rw-r--r--Changes1
-rw-r--r--eio.c11
-rw-r--r--libeio.m44
3 files changed, 9 insertions, 7 deletions
diff --git a/Changes b/Changes
index 78a3459..f943689 100644
--- a/Changes
+++ b/Changes
@@ -18,6 +18,7 @@ TODO: maybe add mincore support? available on at least darwin, solaris, linux, f
- "outbundled" from IO::AIO.
- eio_set_max_polltime did not properly convert time to ticks.
- tentatively support darwin in sendfile.
+ - fix freebsd/darwin sendfile.
- also use sendfile emulation for ENOTSUP and EOPNOTSUPP
error codes.
- add OS-independent EIO_MT_* and EIO_MS_* flag enums.
diff --git a/eio.c b/eio.c
index 7d54ca9..609b28c 100644
--- a/eio.c
+++ b/eio.c
@@ -82,7 +82,7 @@
# include <dirent.h>
/* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */
-# if __freebsd || defined __NetBSD__ || defined __OpenBSD__
+# if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
# define _DIRENT_HAVE_D_TYPE /* sigh */
# define D_INO(de) (de)->d_fileno
# define D_NAMLEN(de) (de)->d_namlen
@@ -108,7 +108,7 @@
#if HAVE_SENDFILE
# if __linux
# include <sys/sendfile.h>
-# elif __freebsd || defined __APPLE__
+# elif __FreeBSD__ || defined __APPLE__
# include <sys/socket.h>
# include <sys/uio.h>
# elif __hpux
@@ -911,7 +911,7 @@ eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self)
# if __linux
res = sendfile (ofd, ifd, &offset, count);
-# elif __freebsd
+# elif __FreeBSD__
/*
* Of course, the freebsd sendfile is a dire hack with no thoughts
* wasted on making it similar to other I/O functions.
@@ -920,7 +920,8 @@ 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);
- if (res < 0 && sbytes)
+ /* freebsd' sendfile will return 0 when success */
+ if (res == 0 && sbytes)
/* maybe only on EAGAIN: as usual, the manpage leaves you guessing */
res = sbytes;
}
@@ -931,7 +932,7 @@ 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)
+ if (res == 0 && errno == EAGAIN && sbytes)
res = sbytes;
}
diff --git a/libeio.m4 b/libeio.m4
index e80e008..0a737d3 100644
--- a/libeio.m4
+++ b/libeio.m4
@@ -64,7 +64,7 @@ AC_CACHE_CHECK(for sendfile, ac_cv_sendfile, [AC_LINK_IFELSE([
# include <sys/types.h>
#if __linux
# include <sys/sendfile.h>
-#elif __freebsd || defined __APPLE__
+#elif __FreeBSD__ || defined __APPLE__
# include <sys/socket.h>
# include <sys/uio.h>
#elif __hpux
@@ -80,7 +80,7 @@ int main(void)
ssize_t res;
#if __linux
res = sendfile (fd, fd, offset, count);
-#elif __freebsd
+#elif __FreeBSD__
res = sendfile (fd, fd, offset, count, 0, &offset, 0);
#elif __hpux
res = sendfile (fd, fd, offset, count, 0, 0);