annotate src/lib/sendfile-util.c @ 9451:9fff30644260 HEAD

istream-concat: Fixed a lot of bugs.
author Timo Sirainen <tss@iki.fi>
date Mon, 26 Oct 2009 17:06:57 -0400
parents 46c9e3364d81
children 00cd9aacd03c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8590
b9faf4db2a9f Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
1741
9df02b1533b3 Removed most of the license comments from src/lib/*.c. It's just fine to
Timo Sirainen <tss@iki.fi>
parents: 1345
diff changeset
2
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 /* kludge a bit to remove _FILE_OFFSET_BITS definition from config.h.
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 It's required to be able to include sys/sendfile.h with Linux. */
3476
bb88b67d72b2 Include just "config.h", not "../../config.h". The absolute path breaks
Timo Sirainen <tss@iki.fi>
parents: 3098
diff changeset
5 #include "config.h"
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #undef HAVE_CONFIG_H
528
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
7
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
8 #ifdef HAVE_LINUX_SENDFILE
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
9 # undef _FILE_OFFSET_BITS
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
10 #endif
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 #include "lib.h"
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 #include "sendfile-util.h"
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14
528
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
15 #ifdef HAVE_LINUX_SENDFILE
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 #include <sys/sendfile.h>
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 ssize_t safe_sendfile(int out_fd, int in_fd, uoff_t *offset, size_t count)
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 {
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 /* REMEBER: uoff_t and off_t may not be of same size. */
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 off_t safe_offset;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 ssize_t ret;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24
3098
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
25 if (count == 0)
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
26 return 0;
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
27
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28 /* make sure given offset fits into off_t */
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29 if (sizeof(off_t) * CHAR_BIT == 32) {
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 /* 32bit off_t */
1146
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
31 if (*offset >= 2147483647L) {
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
32 errno = EINVAL;
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 return -1;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34 }
1146
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
35 if (count > 2147483647L - *offset)
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
36 count = 2147483647L - *offset;
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 } else {
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38 /* they're most likely the same size. if not, fix this
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 code later */
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 i_assert(sizeof(off_t) == sizeof(uoff_t));
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41
1146
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
42 if (*offset >= OFF_T_MAX) {
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
43 errno = EINVAL;
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 return -1;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 }
1146
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
46 if (count > OFF_T_MAX - *offset)
ee4bdf40ec10 Bugfixes to handling >2GB files.
Timo Sirainen <tss@iki.fi>
parents: 1114
diff changeset
47 count = OFF_T_MAX - *offset;
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 }
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 safe_offset = (off_t)*offset;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 ret = sendfile(out_fd, in_fd, &safe_offset, count);
9060
46c9e3364d81 safe_sendfile(): Error handling fixes for Linux and Solaris.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
52 /* ret=0 : trying to read past EOF, errno = EPIPE : remote is gone */
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 *offset = (uoff_t)safe_offset;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 return ret;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55 }
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56
528
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
57 #elif defined(HAVE_FREEBSD_SENDFILE)
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
58
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
59 #include <sys/socket.h>
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
60 #include <sys/uio.h>
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
61
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
62 ssize_t safe_sendfile(int out_fd, int in_fd, uoff_t *offset, size_t count)
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
63 {
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
64 struct sf_hdtr hdtr;
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
65 off_t sbytes;
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
66 int ret;
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
67
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
68 i_assert(count <= SSIZE_T_MAX);
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
69
3098
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
70 if (count == 0) {
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
71 /* if count=0 is passed to sendfile(), it sends everything
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
72 from in_fd until EOF. We don't want that. */
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
73 return 0;
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
74 }
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
75
528
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
76 memset(&hdtr, 0, sizeof(hdtr));
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
77 ret = sendfile(in_fd, out_fd, *offset, count, &hdtr, &sbytes, 0);
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
78
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
79 *offset += sbytes;
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
80
2741
95fd6024e1e2 FreeBSD fix
Timo Sirainen <tss@iki.fi>
parents: 2653
diff changeset
81 if (ret == 0 || (ret < 0 && errno == EAGAIN && sbytes > 0))
528
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
82 return (ssize_t)sbytes;
1114
44b531fbb32a FreeBSD's sendfile() works only with sockets. Replace errno with EINVAL to
Timo Sirainen <tss@iki.fi>
parents: 976
diff changeset
83 else {
44b531fbb32a FreeBSD's sendfile() works only with sockets. Replace errno with EINVAL to
Timo Sirainen <tss@iki.fi>
parents: 976
diff changeset
84 if (errno == ENOTSOCK) {
44b531fbb32a FreeBSD's sendfile() works only with sockets. Replace errno with EINVAL to
Timo Sirainen <tss@iki.fi>
parents: 976
diff changeset
85 /* out_fd wasn't a socket. behave as if sendfile()
44b531fbb32a FreeBSD's sendfile() works only with sockets. Replace errno with EINVAL to
Timo Sirainen <tss@iki.fi>
parents: 976
diff changeset
86 wasn't supported at all. */
44b531fbb32a FreeBSD's sendfile() works only with sockets. Replace errno with EINVAL to
Timo Sirainen <tss@iki.fi>
parents: 976
diff changeset
87 errno = EINVAL;
44b531fbb32a FreeBSD's sendfile() works only with sockets. Replace errno with EINVAL to
Timo Sirainen <tss@iki.fi>
parents: 976
diff changeset
88 }
528
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
89 return -1;
1114
44b531fbb32a FreeBSD's sendfile() works only with sockets. Replace errno with EINVAL to
Timo Sirainen <tss@iki.fi>
parents: 976
diff changeset
90 }
528
a95b1ccff82e Support FreeBSD-compatible sendfile(). Completely untested.
Timo Sirainen <tss@iki.fi>
parents: 58
diff changeset
91 }
976
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
92
2035
0e65efd14eda Solaris: Move from sendfilev() to sendfile() (was it always there?). Make
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
93 #elif defined (HAVE_SOLARIS_SENDFILE)
976
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
94
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
95 #include <sys/sendfile.h>
1165
69d922a1d051 Solaris 9 seems to kernel panic if sendfilev() is used with non-socket.
Timo Sirainen <tss@iki.fi>
parents: 1146
diff changeset
96 #include "network.h"
976
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
97
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
98 ssize_t safe_sendfile(int out_fd, int in_fd, uoff_t *offset, size_t count)
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
99 {
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
100 ssize_t ret;
2653
dd015282fbdf Warning fix with Solaris.
Timo Sirainen <tss@iki.fi>
parents: 2035
diff changeset
101 off_t s_offset;
976
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
102
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
103 i_assert(count <= SSIZE_T_MAX);
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
104
3098
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
105 if (count == 0)
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
106 return 0;
80f7ea6aa94c Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.
Timo Sirainen <tss@iki.fi>
parents: 2741
diff changeset
107
1345
04b81672c3a3 Call safe_sendfile() only with sockets, and also with files under Linux.
Timo Sirainen <tss@iki.fi>
parents: 1165
diff changeset
108 /* NOTE: if outfd is not a socket, some Solaris versions will
1165
69d922a1d051 Solaris 9 seems to kernel panic if sendfilev() is used with non-socket.
Timo Sirainen <tss@iki.fi>
parents: 1146
diff changeset
109 kernel panic */
69d922a1d051 Solaris 9 seems to kernel panic if sendfilev() is used with non-socket.
Timo Sirainen <tss@iki.fi>
parents: 1146
diff changeset
110
2653
dd015282fbdf Warning fix with Solaris.
Timo Sirainen <tss@iki.fi>
parents: 2035
diff changeset
111 s_offset = (off_t)*offset;
dd015282fbdf Warning fix with Solaris.
Timo Sirainen <tss@iki.fi>
parents: 2035
diff changeset
112 ret = sendfile(out_fd, in_fd, &s_offset, count);
6239
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
113
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
114 if (ret < 0) {
9060
46c9e3364d81 safe_sendfile(): Error handling fixes for Linux and Solaris.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
115 /* if remote is gone, EPIPE is returned */
46c9e3364d81 safe_sendfile(): Error handling fixes for Linux and Solaris.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
116 if (errno == EINVAL) {
46c9e3364d81 safe_sendfile(): Error handling fixes for Linux and Solaris.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
117 /* most likely trying to read past EOF */
46c9e3364d81 safe_sendfile(): Error handling fixes for Linux and Solaris.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
118 ret = 0;
46c9e3364d81 safe_sendfile(): Error handling fixes for Linux and Solaris.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
119 } else if (errno == EAFNOSUPPORT) {
6239
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
120 /* not supported, return Linux-like EINVAL so caller
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
121 sees only consistent errnos. */
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
122 errno = EINVAL;
6240
3a1ff50a57b7 Solaris: Ignore also other errors (EINTR?) if some data was sent.
Timo Sirainen <tss@iki.fi>
parents: 6239
diff changeset
123 } else if (s_offset != (off_t)*offset) {
3a1ff50a57b7 Solaris: Ignore also other errors (EINTR?) if some data was sent.
Timo Sirainen <tss@iki.fi>
parents: 6239
diff changeset
124 /* some data was sent, return it */
6239
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
125 i_assert(s_offset > (off_t)*offset);
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
126 ret = s_offset - (off_t)*offset;
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
127 }
b24199c8612d Solaris: We didn't handle EAGAIN correctly.
Timo Sirainen <tss@iki.fi>
parents: 4311
diff changeset
128 }
2653
dd015282fbdf Warning fix with Solaris.
Timo Sirainen <tss@iki.fi>
parents: 2035
diff changeset
129 *offset = (uoff_t)s_offset;
2035
0e65efd14eda Solaris: Move from sendfilev() to sendfile() (was it always there?). Make
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
130 return ret;
976
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
131 }
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
132
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
133 #else
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 6240
diff changeset
134 ssize_t safe_sendfile(int out_fd ATTR_UNUSED, int in_fd ATTR_UNUSED,
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 6240
diff changeset
135 uoff_t *offset ATTR_UNUSED,
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 6240
diff changeset
136 size_t count ATTR_UNUSED)
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 {
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 errno = EINVAL;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
139 return -1;
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
140 }
976
b3e0f857981c Support for Solaris sendfilev(). Entirely untested, hope it works.
Timo Sirainen <tss@iki.fi>
parents: 528
diff changeset
141
58
8aaa39e7aec8 sendfile() works now properly with 64bit off_t
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
142 #endif