dovecot-2.0: safe_sendfile(): Error handling fixes for Linux and...
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 19 20:37:49 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/c96abc68b115
changeset: 9325:c96abc68b115
user: Timo Sirainen <tss at iki.fi>
date: Tue May 19 13:34:54 2009 -0400
description:
safe_sendfile(): Error handling fixes for Linux and Solaris.
diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
src/lib/sendfile-util.c | 12 ++++++------
diffs (30 lines):
diff -r 9c6597ba9e3e -r c96abc68b115 src/lib/sendfile-util.c
--- a/src/lib/sendfile-util.c Mon May 18 14:01:23 2009 -0400
+++ b/src/lib/sendfile-util.c Tue May 19 13:34:54 2009 -0400
@@ -49,12 +49,8 @@ ssize_t safe_sendfile(int out_fd, int in
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 @@ ssize_t safe_sendfile(int out_fd, int in
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;
More information about the dovecot-cvs
mailing list