changeset 16774:28df180ec3ab

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.
author Timo Sirainen <tss@iki.fi>
date Fri, 20 Sep 2013 00:14:11 +0300
parents 76d5e3c8cec3
children 0eee8caeaa53
files src/lib/istream-file.c
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
 		}