contrib/chg/hgclient.c
changeset 30679 fe11f466880d
parent 30675 112915e9a363
child 30726 dd897eb1699e
--- a/contrib/chg/hgclient.c	Sun Dec 25 03:06:55 2016 +0530
+++ b/contrib/chg/hgclient.c	Sun Dec 25 23:32:11 2016 +0000
@@ -457,16 +457,17 @@
 
 	/* real connect */
 	int r = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
+	if (r < 0) {
+		if (errno != ENOENT && errno != ECONNREFUSED)
+			abortmsgerrno("cannot connect to %s", sockname);
+	}
 	if (bakfd != -1) {
 		fchdirx(bakfd);
 		close(bakfd);
 	}
-
 	if (r < 0) {
 		close(fd);
-		if (errno == ENOENT || errno == ECONNREFUSED)
-			return NULL;
-		abortmsgerrno("cannot connect to %s", addr.sun_path);
+		return NULL;
 	}
 	debugmsg("connected to %s", addr.sun_path);