summaryrefslogtreecommitdiffstats
path: root/src/fuse
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-07 16:21:37 +0100
committerSimon Rettberg2017-11-07 16:21:37 +0100
commit61c576e2ecf1c77470223b24b4314a1659aa07b6 (patch)
treed7163ea27db944dc48764dcfb7633563d2a6d475 /src/fuse
parent[SHARED] Add log_hasMask() to check if a certain loglevel is set (diff)
downloaddnbd3-61c576e2ecf1c77470223b24b4314a1659aa07b6.tar.gz
dnbd3-61c576e2ecf1c77470223b24b4314a1659aa07b6.tar.xz
dnbd3-61c576e2ecf1c77470223b24b4314a1659aa07b6.zip
[FUSE] Split final multiConnect-wait across multiple calls
There might be more than one pending connect, but each call to multiConnect() can return at most one fd, so we could be ignoring some successful connections.
Diffstat (limited to 'src/fuse')
-rw-r--r--src/fuse/connection.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/fuse/connection.c b/src/fuse/connection.c
index 5162364..f29b439 100644
--- a/src/fuse/connection.c
+++ b/src/fuse/connection.c
@@ -125,12 +125,12 @@ bool connection_init(const char *hosts, const char *lowerImage, const uint16_t r
} while ( end != NULL && altIndex < MAX_ALTS );
logadd( LOG_INFO, "Got %d servers from init call", altIndex );
// Connect
- for ( int i = 0; i <= altIndex; ++i ) {
- if ( i == altIndex ) {
- // Last iteration - no corresponding slot in altservers, this
- // is just so we can make a final call with longer timeout
- sock = sock_multiConnect( cons, NULL, 2000, 1000 );
- if ( sock == -1 || sock == -2 ) {
+ for ( int i = 0; i < altIndex + 5; ++i ) {
+ if ( i >= altIndex ) {
+ // Additional iteration - no corresponding slot in altservers, this
+ // is just so we can make a final calls with longer timeout
+ sock = sock_multiConnect( cons, NULL, 400, 1000 );
+ if ( sock == -2 ) {
logadd( LOG_ERROR, "Could not connect to any host" );
sock = -1;
break;
@@ -140,9 +140,9 @@ bool connection_init(const char *hosts, const char *lowerImage, const uint16_t r
continue;
// Try to connect - 100ms timeout
sock = sock_multiConnect( cons, &altservers[i].host, 100, 1000 );
- if ( sock == -2 || sock == -1 )
- continue;
}
+ if ( sock == -2 || sock == -1 )
+ continue;
salen = sizeof(sa);
if ( getpeername( sock, (struct sockaddr*)&sa, &salen ) == -1 ) {
logadd( LOG_ERROR, "getpeername on successful connection failed!? (errno=%d)", errno );