diff options
author | Pavel Roskin <plroskin@gmail.com> | 2016-09-04 09:26:37 -0700 |
---|---|---|
committer | Pavel Roskin <plroskin@gmail.com> | 2016-09-08 22:28:38 -0700 |
commit | 7d03d1a3e90efe45da02c6fa3504f20a88f4b244 (patch) | |
tree | 43a38bbeb2fb3eb5d3cf3a1520304f5ed6dd1d1a /common | |
parent | 5465b8c85efda20a79d23db28fde7ee403aec8f3 (diff) | |
download | xrdp-proprietary-7d03d1a3e90efe45da02c6fa3504f20a88f4b244.tar.gz xrdp-proprietary-7d03d1a3e90efe45da02c6fa3504f20a88f4b244.zip |
Fix outgoing connections on Mac OSX
connect() on an already established connection returns error with errno
set to EISCONN. Treat it as success.
Diffstat (limited to 'common')
-rw-r--r-- | common/os_calls.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 8a294971..9ba6dfc6 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -763,6 +763,13 @@ g_tcp_connect(int sck, const char *address, const char *port) } } } + + /* Mac OSX connect() returns -1 for already established connections */ + if (res == -1 && errno == EISCONN) + { + res = 0; + } + return res; } #else @@ -771,6 +778,7 @@ g_tcp_connect(int sck, const char* address, const char* port) { struct sockaddr_in s; struct hostent* h; + int res; g_memset(&s, 0, sizeof(struct sockaddr_in)); s.sin_family = AF_INET; @@ -793,7 +801,15 @@ g_tcp_connect(int sck, const char* address, const char* port) } } } - return connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); + res = connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); + + /* Mac OSX connect() returns -1 for already established connections */ + if (res == -1 && errno == EISCONN) + { + res = 0; + } + + return res; } #endif |