dovecot: Solaris: We didn't handle EAGAIN correctly.
dovecot at dovecot.org
dovecot at dovecot.org
Thu Aug 9 13:36:35 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/b24199c8612d
changeset: 6239:b24199c8612d
user: Timo Sirainen <tss at iki.fi>
date: Thu Aug 09 13:36:32 2007 +0300
description:
Solaris: We didn't handle EAGAIN correctly.
diffstat:
1 file changed, 12 insertions(+), 6 deletions(-)
src/lib/sendfile-util.c | 18 ++++++++++++------
diffs (29 lines):
diff -r 458aa25822fb -r b24199c8612d src/lib/sendfile-util.c
--- a/src/lib/sendfile-util.c Wed Aug 08 17:14:30 2007 +0300
+++ b/src/lib/sendfile-util.c Thu Aug 09 13:36:32 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 (errno == EAGAIN && s_offset != (off_t)*offset) {
+ /* some data was sent, return them */
+ 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