ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/eio.c
(Generate patch)

Comparing libeio/eio.c (file contents):
Revision 1.49 by root, Sat Jan 2 14:24:32 2010 UTC vs.
Revision 1.50 by root, Thu Jan 7 17:18:08 2010 UTC

80# include <utime.h> 80# include <utime.h>
81# include <signal.h> 81# include <signal.h>
82# include <dirent.h> 82# include <dirent.h>
83 83
84/* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ 84/* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */
85# if __freebsd || defined __NetBSD__ || defined __OpenBSD__ 85# if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
86# define _DIRENT_HAVE_D_TYPE /* sigh */ 86# define _DIRENT_HAVE_D_TYPE /* sigh */
87# define D_INO(de) (de)->d_fileno 87# define D_INO(de) (de)->d_fileno
88# define D_NAMLEN(de) (de)->d_namlen 88# define D_NAMLEN(de) (de)->d_namlen
89# elif __linux || defined d_ino || _XOPEN_SOURCE >= 600 89# elif __linux || defined d_ino || _XOPEN_SOURCE >= 600
90# define D_INO(de) (de)->d_ino 90# define D_INO(de) (de)->d_ino
106#endif 106#endif
107 107
108#if HAVE_SENDFILE 108#if HAVE_SENDFILE
109# if __linux 109# if __linux
110# include <sys/sendfile.h> 110# include <sys/sendfile.h>
111# elif __freebsd || defined __APPLE__ 111# elif __FreeBSD__ || defined __APPLE__
112# include <sys/socket.h> 112# include <sys/socket.h>
113# include <sys/uio.h> 113# include <sys/uio.h>
114# elif __hpux 114# elif __hpux
115# include <sys/socket.h> 115# include <sys/socket.h>
116# elif __solaris 116# elif __solaris
909 909
910#if HAVE_SENDFILE 910#if HAVE_SENDFILE
911# if __linux 911# if __linux
912 res = sendfile (ofd, ifd, &offset, count); 912 res = sendfile (ofd, ifd, &offset, count);
913 913
914# elif __freebsd 914# elif __FreeBSD__
915 /* 915 /*
916 * Of course, the freebsd sendfile is a dire hack with no thoughts 916 * Of course, the freebsd sendfile is a dire hack with no thoughts
917 * wasted on making it similar to other I/O functions. 917 * wasted on making it similar to other I/O functions.
918 */ 918 */
919 { 919 {
920 off_t sbytes; 920 off_t sbytes;
921 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); 921 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0);
922 922
923 /* freebsd' sendfile will return 0 when success */
923 if (res < 0 && sbytes) 924 if (res == 0 && sbytes)
924 /* maybe only on EAGAIN: as usual, the manpage leaves you guessing */ 925 /* maybe only on EAGAIN: as usual, the manpage leaves you guessing */
925 res = sbytes; 926 res = sbytes;
926 } 927 }
927 928
928# elif defined (__APPLE__) 929# elif defined (__APPLE__)
929 930
930 { 931 {
931 off_t sbytes = count; 932 off_t sbytes = count;
932 res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); 933 res = sendfile (ifd, ofd, offset, &sbytes, 0, 0);
933 934
934 if (res < 0 && errno == EAGAIN && sbytes) 935 if (res == 0 && errno == EAGAIN && sbytes)
935 res = sbytes; 936 res = sbytes;
936 } 937 }
937 938
938# elif __hpux 939# elif __hpux
939 res = sendfile (ofd, ifd, offset, count, 0, 0); 940 res = sendfile (ofd, ifd, offset, count, 0, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines