[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torsocks/master] Fix: add missing errno to handle non-blocking connect()



commit 7ed0346b388350c71a315e6c2567a6178c6bc128
Author: David Goulet <dgoulet@xxxxxxxxx>
Date:   Wed Nov 6 19:41:52 2013 -0500

    Fix: add missing errno to handle non-blocking connect()
    
    Fixes #16
    
    Reported-by: adrelanos <adrelanos@xxxxxxxxxx>
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxx>
---
 src/common/socks5.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/common/socks5.c b/src/common/socks5.c
index fcd48b6..ede3594 100644
--- a/src/common/socks5.c
+++ b/src/common/socks5.c
@@ -146,8 +146,14 @@ int socks5_connect(struct connection *conn)
 	do {
 		/* Use the original libc connect() to the Tor. */
 		ret = tsocks_libc_connect(conn->fd, socks5_addr, sizeof(*socks5_addr));
-	} while (ret < 0 && (errno == EINTR || errno == EINPROGRESS));
+	} while (ret < 0 &&
+			(errno == EINTR || errno == EINPROGRESS || errno == EALREADY));
 	if (ret < 0) {
+		/* The non blocking socket is now connected. */
+		if (errno == EISCONN) {
+			ret = 0;
+			goto error;
+		}
 		ret = -errno;
 		PERROR("socks5 libc connect");
 	}



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits