changeset 1053:fd3712d1ff7f

Better failure handling
author Matt Johnston <matt@ucc.asn.au>
date Sat, 28 Feb 2015 23:49:39 +0800
parents 359fba4b1a49
children c71df09bc610 063c38ea622b
files netio.c
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/netio.c	Sat Feb 28 23:24:30 2015 +0800
+++ b/netio.c	Sat Feb 28 23:49:39 2015 +0800
@@ -169,11 +169,10 @@
 		snprintf(c->errstring, len, "Error resolving '%s' port '%s'. %s", 
 				remotehost, remoteport, gai_strerror(err));
 		TRACE(("Error resolving: %s", gai_strerror(err)))
-		return NULL;
+	} else {
+		c->res_iter = c->res;
 	}
 
-	c->res_iter = c->res;
-
 	return c;
 }
 
@@ -220,7 +219,7 @@
 		socklen_t vallen = sizeof(val);
 		struct dropbear_progress_connection *c = iter->item;
 
-		if (!FD_ISSET(c->sock, writefd)) {
+		if (c->sock < 0 || !FD_ISSET(c->sock, writefd)) {
 			continue;
 		}