From 61c576e2ecf1c77470223b24b4314a1659aa07b6 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 7 Nov 2017 16:21:37 +0100 Subject: [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. --- src/fuse/connection.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/fuse') 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 ); -- cgit v1.2.3-55-g7522