@@ -475,30 +475,28 @@ impl Session {
475
475
hosts : & mut impl Iterator < Item = ( & ' a str , u16 ) > ,
476
476
deadline : & mut Sleep ,
477
477
) -> Result < ( TcpStream , ( & ' a str , u16 ) ) , Error > {
478
- loop {
479
- let addr = match hosts. next ( ) {
480
- None => return Err ( Error :: NoHosts ) ,
481
- Some ( addr) => addr,
482
- } ;
483
- select ! {
484
- _ = unsafe { Pin :: new_unchecked( deadline) } => return Err ( Error :: Timeout ) ,
485
- _ = time:: sleep( self . connection_timeout) => {
486
- log:: debug!( "ZooKeeper fails to connect to {}:{} in {}ms" , addr. 0 , addr. 1 , self . connection_timeout. as_millis( ) ) ;
487
- return Err ( Error :: ConnectionLoss )
488
- } ,
489
- r = TcpStream :: connect( addr) => {
490
- return match r {
491
- Err ( err) => {
492
- log:: debug!( "ZooKeeper fails to connect to {}:{} due to {}" , addr. 0 , addr. 1 , err) ;
493
- Err ( Error :: ConnectionLoss )
494
- } ,
495
- Ok ( sock) => {
496
- log:: debug!( "ZooKeeper succeeds in connectiong to {}:{}" , addr. 0 , addr. 1 ) ;
497
- Ok ( ( sock, addr) )
498
- } ,
499
- } ;
500
- } ,
501
- }
478
+ let addr = match hosts. next ( ) {
479
+ None => return Err ( Error :: NoHosts ) ,
480
+ Some ( addr) => addr,
481
+ } ;
482
+ select ! {
483
+ _ = unsafe { Pin :: new_unchecked( deadline) } => Err ( Error :: Timeout ) ,
484
+ _ = time:: sleep( self . connection_timeout) => {
485
+ log:: debug!( "ZooKeeper fails to connect to {}:{} in {}ms" , addr. 0 , addr. 1 , self . connection_timeout. as_millis( ) ) ;
486
+ Err ( Error :: ConnectionLoss )
487
+ } ,
488
+ r = TcpStream :: connect( addr) => {
489
+ match r {
490
+ Err ( err) => {
491
+ log:: debug!( "ZooKeeper fails to connect to {}:{} due to {}" , addr. 0 , addr. 1 , err) ;
492
+ Err ( Error :: ConnectionLoss )
493
+ } ,
494
+ Ok ( sock) => {
495
+ log:: debug!( "ZooKeeper succeeds in connectiong to {}:{}" , addr. 0 , addr. 1 ) ;
496
+ Ok ( ( sock, addr) )
497
+ } ,
498
+ }
499
+ } ,
502
500
}
503
501
}
504
502
0 commit comments