Klaus Demo bjoern / 4019be9
FreeBSD sendfile implementation Jonas Haag 7 years ago
1 changed file(s) with 16 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
11
22 #define SENDFILE_CHUNK_SIZE 16*1024
33
4 #ifdef __APPLE__
4 #if defined __APPLE__
55
66 /* OS X */
77
1212 off_t len = SENDFILE_CHUNK_SIZE;
1313 if(sendfile(in_fd, out_fd, 0, &len, NULL, 0) == -1)
1414 return -1;
15 return len;
16 }
17
18 #elif defined __FreeBSD__
19
20 /* FreeBSD */
21
22 #include <sys/socket.h>
23 #include <sys/types.h>
24
25 ssize_t portable_sendfile(int out_fd, int in_fd) {
26 off_t len;
27 if (sendfile(in_fd, out_fd, 0, SENDFILE_CHUNK_SIZE, NULL, &len, 0) == -1) {
28 return -1;
29 }
1530 return len;
1631 }
1732