[tor-commits] [torsocks/master] Fix: add missing errno to handle non-blocking connect()
dgoulet at torproject.org
dgoulet at torproject.org
Fri Apr 4 22:40:27 UTC 2014
commit 7ed0346b388350c71a315e6c2567a6178c6bc128
Author: David Goulet <dgoulet at ev0ke.net>
Date: Wed Nov 6 19:41:52 2013 -0500
Fix: add missing errno to handle non-blocking connect()
Fixes #16
Reported-by: adrelanos <adrelanos at riseup.net>
Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
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");
}
More information about the tor-commits
mailing list