about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-08-25 21:06:14 +0000
committerMarco Peereboom <marco@conformal.com>2011-08-25 21:06:14 +0000
commit62316d9cbf7f5502f7fdfe9acdbd16c3a29a4a08 (patch)
tree4393738ec1cade83479efa08011c0a9199f4c3f4
parent15ea14e907bced2b3678203b78abc03b860bc3a1 (diff)
downloadxombrero-62316d9cbf7f5502f7fdfe9acdbd16c3a29a4a08.tar.gz
rework connect logic on cert retrieval
this was prompted by a bug report from todd

help and ok toddrework connect logic on cert retrieval

this was prompted by a bug report from todd

help and ok toddrework connect logic on cert retrieval

this was prompted by a bug report from todd

help and ok toddrework connect logic on cert retrieval

this was prompted by a bug report from todd

help and ok todd
-rw-r--r--xxxterm.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 25a429b..146e737 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -3364,25 +3364,26 @@ connect_socket_from_uri(struct tab *t, const gchar *uri, char *domain,
 	}
 
 	for (ai = res; ai; ai = ai->ai_next) {
+		if (s != -1) {
+			close(s);
+			s = -1;
+		}
+
 		if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
 			continue;
-
 		s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
-		if (s == -1) {
-			show_oops(t, "socket failed: %s", strerror(errno));
-			goto done;
-		}
+		if (s == -1)
+			continue;
 		if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on,
-		    sizeof(on)) == -1) {
-			show_oops(t, "setsockopt failed: %s", strerror(errno));
-			goto done;
-		}
-		if (connect(s, ai->ai_addr, ai->ai_addrlen) == -1) {
-			show_oops(t, "connect failed: %s", strerror(errno));
-			goto done;
-		}
-
-		break;
+		    sizeof(on)) == -1)
+			continue;
+		if (connect(s, ai->ai_addr, ai->ai_addrlen) == 0)
+			break;
+	}
+	if (s == -1) {
+		show_oops(t, "could not obtain certificates from: %s",
+		    su->host);
+		goto done;
 	}
 
 	if (domain)