commit 13653186775d65625930341a838511325e246f18
Author: Robert Hogan <[email protected]>
Date: Tue Oct 25 22:50:11 2011 +0100
Issue 32: Irssi locks connecting to hidden service
During connect() we can end up getting a EWOULDBLOCK/EAGAIN while
talking to the SOCKS proxy. This seems to happen when attempting
to read a SOCKSV4 connect response from Tor when using the command
'torsocks irssi -c 4eiruntyxxbgfv7o.onion' for example.
EWOULDBLOCK isn't a valid error during connect(), so if we get it
don't return it to the client - use EINPROGRESS instead.
Diagnosed and patched by: [email protected]
---
src/torsocks.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/torsocks.c b/src/torsocks.c
index c4004d9..f559eec 100644
--- a/src/torsocks.c
+++ b/src/torsocks.c
@@ -417,6 +417,12 @@ int torsocks_connect_guts(CONNECT_SIGNATURE, int
(*original_connect)(CONNECT_SIG
if ((newconn->state == FAILED) || (newconn->state == DONE))
kill_socks_request(newconn);
errno = rc;
+ /* We may get either of these if there are no bytes to read from
+ the non-blocking connection in handle_request(). Since we are
+ wrapping connect() here we can't return EWOULDBLOCK/EAGAIN
+ so override it with something the client will accept.*/
+ if (errno == EWOULDBLOCK || errno == EAGAIN)
+ errno = EINPROGRESS;
return((rc ? -1 : 0));
}
}
_______________________________________________
tor-commits mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits