dovecot-2.2: istream-file: Assert-crash if read() fails with EBADF.

dovecot at dovecot.org dovecot at dovecot.org
Fri Sep 20 00:14:23 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/28df180ec3ab
changeset: 16774:28df180ec3ab
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Sep 20 00:14:11 2013 +0300
description:
istream-file: Assert-crash if read() fails with EBADF.
Something's already wrong at that point and it may not be safe to continue.
Also crashing makes it easier to debug such situation.

diffstat:

 src/lib/istream-file.c |  3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diffs (13 lines):

diff -r 76d5e3c8cec3 -r 28df180ec3ab src/lib/istream-file.c
--- a/src/lib/istream-file.c	Fri Sep 20 00:12:45 2013 +0300
+++ b/src/lib/istream-file.c	Fri Sep 20 00:14:11 2013 +0300
@@ -94,6 +94,9 @@
 			ret = 0;
 		} else {
 			i_assert(errno != 0);
+			/* if we get EBADF for a valid fd, it means something's
+			   really wrong and we'd better just crash. */
+			i_assert(errno != EBADF);
 			stream->istream.stream_errno = errno;
 			return -1;
 		}


More information about the dovecot-cvs mailing list