diff options
author | Simon Rettberg | 2020-07-21 16:45:50 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-07-21 16:45:50 +0200 |
commit | c112a4a797c74fb19a06e105c7f832759863d3d5 (patch) | |
tree | 7f7d51774fe8c009638d70e643e04927a3335270 /src/shared | |
parent | [FUSE] Properly signal worker threads to exit on shutdown (diff) | |
download | dnbd3-c112a4a797c74fb19a06e105c7f832759863d3d5.tar.gz dnbd3-c112a4a797c74fb19a06e105c7f832759863d3d5.tar.xz dnbd3-c112a4a797c74fb19a06e105c7f832759863d3d5.zip |
[SHARED] Fix: connect with timeout returns socket handle on EINPROGRESS
Only if we request non-blocking connect (connect_ms == -1) this function
should return a socket fd that is not actually connected. Otherwise,
consder this a failure, close the sock fd, and return -1.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/sockhelper.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/shared/sockhelper.c b/src/shared/sockhelper.c index ab34aa1..582420a 100644 --- a/src/shared/sockhelper.c +++ b/src/shared/sockhelper.c @@ -58,7 +58,7 @@ int sock_connect(const dnbd3_host_t * const addr, const int connect_ms, const in } for ( int i = 0; i < 5; ++i ) { int ret = connect( client_sock, (struct sockaddr *)&ss, addrlen ); - if ( ret != -1 || errno == EINPROGRESS || errno == EISCONN ) break; + if ( ret != -1 || ( connect_ms == -1 && errno == EINPROGRESS ) || errno == EISCONN ) break; if ( errno == EINTR ) { // http://www.madore.org/~david/computers/connect-intr.html #ifdef __linux__ |