Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6239:b24199c8612d HEAD
Solaris: We didn't handle EAGAIN correctly.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 09 Aug 2007 13:36:32 +0300 |
parents | 458aa25822fb |
children | 3a1ff50a57b7 |
files | src/lib/sendfile-util.c |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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; }