Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9060:46c9e3364d81 HEAD
safe_sendfile(): Error handling fixes for Linux and Solaris.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 19 May 2009 13:34:54 -0400 |
parents | d42a8623a008 |
children | 3442cd45b502 |
files | src/lib/sendfile-util.c |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/sendfile-util.c Mon May 18 13:15:24 2009 -0400 +++ b/src/lib/sendfile-util.c Tue May 19 13:34:54 2009 -0400 @@ -49,12 +49,8 @@ safe_offset = (off_t)*offset; ret = sendfile(out_fd, in_fd, &safe_offset, count); + /* ret=0 : trying to read past EOF, errno = EPIPE : remote is gone */ *offset = (uoff_t)safe_offset; - - if (ret == 0) { - errno = EPIPE; - ret = -1; - } return ret; } @@ -116,7 +112,11 @@ ret = sendfile(out_fd, in_fd, &s_offset, count); if (ret < 0) { - if (errno == EAFNOSUPPORT) { + /* if remote is gone, EPIPE is returned */ + if (errno == EINVAL) { + /* most likely trying to read past EOF */ + ret = 0; + } else if (errno == EAFNOSUPPORT) { /* not supported, return Linux-like EINVAL so caller sees only consistent errnos. */ errno = EINVAL;