dovecot-1.0: Solaris: If sendfile() failed (e.g. EAGAIN) but som...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Aug 9 13:40:38 EEST 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/696c9d5fcf71
changeset: 5370:696c9d5fcf71
user: Timo Sirainen <tss at iki.fi>
date: Thu Aug 09 13:40:34 2007 +0300
description:
Solaris: If sendfile() failed (e.g. EAGAIN) but some data was already sent,
don't return failure.
diffstat:
1 file changed, 12 insertions(+), 6 deletions(-)
src/lib/sendfile-util.c | 18 ++++++++++++------
diffs (29 lines):
diff -r 1c631fec9c68 -r 696c9d5fcf71 src/lib/sendfile-util.c
--- a/src/lib/sendfile-util.c Wed Aug 08 15:32:04 2007 +0300
+++ b/src/lib/sendfile-util.c Thu Aug 09 13:40:34 2007 +0300
@@ -114,13 +114,19 @@ ssize_t safe_sendfile(int out_fd, int in
s_offset = (off_t)*offset;
ret = sendfile(out_fd, in_fd, &s_offset, count);
+
+ if (ret < 0) {
+ if (errno == EAFNOSUPPORT) {
+ /* not supported, return Linux-like EINVAL so caller
+ sees only consistent errnos. */
+ errno = EINVAL;
+ } else if (s_offset != (off_t)*offset) {
+ /* some data was sent, return it */
+ i_assert(s_offset > (off_t)*offset);
+ ret = s_offset - (off_t)*offset;
+ }
+ }
*offset = (uoff_t)s_offset;
-
- if (ret < 0 && errno == EAFNOSUPPORT) {
- /* not supported, return Linux-like EINVAL so caller
- sees only consistent errnos. */
- errno = EINVAL;
- }
return ret;
}
More information about the dovecot-cvs
mailing list