1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
$NetBSD: patch-ac,v 1.2 2006/09/17 11:45:04 jmmv Exp $
Except for the first two chunks:
https://sourceforge.net/tracker/index.php?func=detail&aid=1252703&group_id=17338&atid=117338
--- tsocks.c.orig 2002-07-16 00:50:52.000000000 +0200
+++ tsocks.c
@@ -68,7 +68,7 @@ static int suid = 0;
static char *conffile = NULL;
/* Exported Function Prototypes */
-void _init(void);
+void __tsocks_init(void) __attribute__ ((__constructor__));
int connect(CONNECT_SIGNATURE);
int select(SELECT_SIGNATURE);
int poll(POLL_SIGNATURE);
@@ -100,7 +100,7 @@ static int read_socksv4_req(struct connr
static int read_socksv5_connect(struct connreq *conn);
static int read_socksv5_auth(struct connreq *conn);
-void _init(void) {
+void __tsocks_init(void) {
#ifdef USE_OLD_DLSYM
void *lib;
#endif
@@ -658,7 +658,7 @@ int poll(POLL_SIGNATURE) {
* come around again (since we can't flag it for read, we don't know
* if there is any data to be read and can't be bothered checking) */
if (conn->selectevents & WRITE) {
- setevents |= POLLOUT;
+ ufds[i].revents |= (conn->selectevents & WRITE);
nevents++;
}
}
@@ -852,7 +852,12 @@ static int connect_server(struct connreq
sizeof(conn->serveraddr));
show_msg(MSGDEBUG, "Connect returned %d, errno is %d\n", rc, errno);
- if (rc) {
+ if (rc && errno == EISCONN) {
+ rc = 0;
+ show_msg(MSGDEBUG, "Socket %d already connected to SOCKET server\n",
+ conn->sockid);
+ conn->state = CONNECTED;
+ } else if (rc) {
if (errno != EINPROGRESS) {
show_msg(MSGERR, "Error %d attempting to connect to SOCKS "
"server (%s)\n", errno, strerror(errno));
|