diff dbutil.c @ 70:b0316ce64e4b

Merging in the changes from 0.41-0.43 main Dropbear tree
author Matt Johnston <matt@ucc.asn.au>
date Thu, 12 Aug 2004 16:41:58 +0000
parents eee77ac31ccc
children 0bf5cebe622c
line wrap: on
line diff
--- a/dbutil.c	Thu Aug 12 15:41:36 2004 +0000
+++ b/dbutil.c	Thu Aug 12 16:41:58 2004 +0000
@@ -121,7 +121,7 @@
 int dropbear_listen(const char* address, const char* port,
 		int *socks, unsigned int sockcount, char **errstring, int *maxfd) {
 
-	struct addrinfo hints, *res, *res0;
+	struct addrinfo hints, *res = NULL, *res0 = NULL;
 	int err;
 	unsigned int nsock;
 	struct linger linger;
@@ -273,7 +273,7 @@
 		}
 
 		if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
-			if (errno == EINPROGRESS) {
+			if (errno == EINPROGRESS && nonblocking) {
 				TRACE(("Connect in progress"));
 				break;
 			} else {
@@ -287,7 +287,7 @@
 		break; /* Success */
 	}
 
-	if (sock < 0) {
+	if (sock < 0 && !(errno == EINPROGRESS && nonblocking)) {
 		/* Failed */
 		if (errstring != NULL && *errstring == NULL) {
 			int len;