diff dbutil.c @ 1022:4121ca987e6a

connect_remote() is now always non-blocking
author Matt Johnston <matt@ucc.asn.au>
date Sat, 14 Feb 2015 09:56:11 +0800
parents 24135c8e1d46
children a00303a7d247 d3925ed45a85
line wrap: on
line diff
--- a/dbutil.c	Fri Feb 13 23:47:53 2015 +0800
+++ b/dbutil.c	Sat Feb 14 09:56:11 2015 +0800
@@ -435,8 +435,7 @@
  * wasn't null, it will be a newly malloced error message */
 
 /* TODO: maxfd */
-int connect_remote(const char* remotehost, const char* remoteport,
-		int nonblocking, char ** errstring) {
+int connect_remote(const char* remotehost, const char* remoteport, char ** errstring) {
 
 	struct addrinfo *res0 = NULL, *res = NULL, hints;
 	int sock;
@@ -475,16 +474,14 @@
 			continue;
 		}
 
-		if (nonblocking) {
-			setnonblocking(sock);
+		setnonblocking(sock);
 
 #if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
-			set_piggyback_ack(sock);
+		set_piggyback_ack(sock);
 #endif
-		}
 
 		if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
-			if (errno == EINPROGRESS && nonblocking) {
+			if (errno == EINPROGRESS) {
 				TRACE(("Connect in progress"))
 				break;
 			} else {
@@ -498,7 +495,7 @@
 		break; /* Success */
 	}
 
-	if (sock < 0 && !(errno == EINPROGRESS && nonblocking)) {
+	if (sock < 0 && !(errno == EINPROGRESS)) {
 		/* Failed */
 		if (errstring != NULL && *errstring == NULL) {
 			int len;