changeset 1224:b661eb87bd26 HEAD

if connection was closed while trying to write data to client, we sometimes crashed. also errno wasn't saved.
author Timo Sirainen <tss@iki.fi>
date Fri, 21 Feb 2003 16:25:33 +0200
parents 52e0830ade13
children 8c85c03e0485
files src/lib/ostream-file.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/ostream-file.c	Fri Feb 21 15:02:16 2003 +0200
+++ b/src/lib/ostream-file.c	Fri Feb 21 16:25:33 2003 +0200
@@ -214,6 +214,7 @@
 	if (ret < 0) {
 		if (errno == EAGAIN || errno == EINTR)
 			return 0;
+		fstream->ostream.ostream.stream_errno = errno;
 		stream_closed(fstream);
 		return -1;
 	}
@@ -431,8 +432,10 @@
 	if (iov_len == 0 || o_stream_writev(fstream, iov, iov_len) < 0 ||
 	    iov[iov_len-1].iov_len == 0) {
 		/* error / all sent */
-		io_remove(fstream->io);
-                fstream->io = NULL;
+		if (fstream->io != NULL) {
+			io_remove(fstream->io);
+			fstream->io = NULL;
+		}
 	}
 }