Ticket #11652: patch-tsocks.c

File patch-tsocks.c, 1.7 KB (added by darren.bane@…, 17 years ago)

Replacement for net/tsocks/files/patch-tsocks.c

Line 
1--- tsocks.c.orig       2007-03-28 12:26:49.000000000 +0100
2+++ tsocks.c    2007-03-28 12:25:55.000000000 +0100
3@@ -76,7 +76,7 @@
4 static char *conffile = NULL;
5 
6 /* Exported Function Prototypes */
7-void _init(void);
8+void _init(void) __attribute__ ((constructor));
9 int connect(CONNECT_SIGNATURE);
10 int select(SELECT_SIGNATURE);
11 int poll(POLL_SIGNATURE);
12@@ -225,9 +225,10 @@
13        struct sockaddr_in *connaddr;
14        struct sockaddr_in peer_address;
15        struct sockaddr_in server_address;
16-   int gotvalidserver = 0, rc, namelen = sizeof(peer_address);
17+   int gotvalidserver = 0, rc;
18        int sock_type = -1;
19-       int sock_type_len = sizeof(sock_type);
20+       socklen_t sock_type_len = sizeof(sock_type);
21+       socklen_t namelen = sizeof(peer_address);
22        unsigned int res = -1;
23        struct serverent *path;
24    struct connreq *newconn;
25@@ -699,7 +700,7 @@
26              * come around again (since we can't flag it for read, we don't know
27              * if there is any data to be read and can't be bothered checking) */
28             if (conn->selectevents & WRITE) {
29-               setevents |= POLLOUT; 
30+               ufds[i].revents |= (conn->selectevents & WRITE);
31                nevents++;
32             }
33          }
34@@ -937,7 +938,12 @@
35                     sizeof(conn->serveraddr));
36 
37    show_msg(MSGDEBUG, "Connect returned %d, errno is %d\n", rc, errno); 
38-   if (rc) {
39+   if (rc && errno == EISCONN) {
40+      rc = 0;
41+      show_msg(MSGDEBUG, "Socket %d already connected to SOCKS server\n",
42+conn->sockid);
43+      conn->state = CONNECTED;
44+   } else if (rc) {
45       if (errno != EINPROGRESS) {
46          show_msg(MSGERR, "Error %d attempting to connect to SOCKS "
47                   "server (%s)\n", errno, strerror(errno));