@@ -77,9 +77,8 @@ impl Client {
7777
7878 if let Some ( client) = client {
7979 return Ok ( client) ;
80- } else {
81- self . connect ( num) . await ?;
8280 }
81+ self . connect ( num) . await ?;
8382 }
8483 }
8584
@@ -120,7 +119,7 @@ impl Client {
120119 } else if connections[ idx] . is_disconnecting ( ) {
121120 let con = connections. remove ( idx) ;
122121 let timeout = cfg. disconnect_timeout ;
123- let _ = ntex_util:: spawn ( async move {
122+ ntex_util:: spawn ( async move {
124123 let _ = con. disconnect ( ) . disconnect_timeout ( timeout) . await ;
125124 } ) ;
126125 } else {
@@ -164,7 +163,7 @@ impl Client {
164163 let inner = self . inner . clone ( ) ;
165164 let waiters = self . waiters . clone ( ) ;
166165
167- let _ = ntex_util:: spawn ( async move {
166+ ntex_util:: spawn ( async move {
168167 let res = match timeout_checked ( inner. config . conn_timeout , ( * inner. connector ) ( ) ) . await {
169168 Ok ( Ok ( io) ) => {
170169 // callbacks for end of stream
@@ -176,7 +175,7 @@ impl Client {
176175 let client = SimpleClient :: with_params (
177176 io,
178177 inner. cfg ,
179- inner. config . scheme . clone ( ) ,
178+ & inner. config . scheme ,
180179 inner. config . authority . clone ( ) ,
181180 inner. config . skip_unknown_streams ,
182181 storage,
@@ -190,7 +189,7 @@ impl Client {
190189 Ok ( ( ) )
191190 }
192191 Ok ( Err ( err) ) => Err ( ClientError :: from ( err) ) ,
193- Err ( _ ) => Err ( ClientError :: HandshakeTimeout ) ,
192+ Err ( ( ) ) => Err ( ClientError :: HandshakeTimeout ) ,
194193 } ;
195194 inner. config . connecting . set ( false ) ;
196195 for waiter in waiters. borrow_mut ( ) . drain ( ..) {
@@ -230,19 +229,18 @@ impl Client {
230229 /// Client is ready when it is possible to start new stream
231230 pub async fn ready ( & self ) {
232231 loop {
233- if !self . is_ready ( ) {
234- // add waiter
235- let ( tx, rx) = self . inner . config . pool . channel ( ) ;
236- self . waiters . borrow_mut ( ) . push_back ( tx) ;
237- let _ = rx. await ;
238- ' inner: while let Some ( tx) = self . waiters . borrow_mut ( ) . pop_front ( ) {
239- if tx. send ( ( ) ) . is_ok ( ) {
240- break ' inner;
241- }
242- }
243- } else {
232+ if self . is_ready ( ) {
244233 break ;
245234 }
235+ // add waiter
236+ let ( tx, rx) = self . inner . config . pool . channel ( ) ;
237+ self . waiters . borrow_mut ( ) . push_back ( tx) ;
238+ let _ = rx. await ;
239+ ' inner: while let Some ( tx) = self . waiters . borrow_mut ( ) . pop_front ( ) {
240+ if tx. send ( ( ) ) . is_ok ( ) {
241+ break ' inner;
242+ }
243+ }
246244 }
247245 }
248246}
@@ -326,7 +324,7 @@ where
326324 maxconn : 16 ,
327325 scheme : Scheme :: HTTP ,
328326 connecting : Cell :: new ( false ) ,
329- connections : Default :: default ( ) ,
327+ connections : RefCell :: default ( ) ,
330328 total_connections : Cell :: new ( 0 ) ,
331329 connect_errors : Cell :: new ( 0 ) ,
332330 pool : pool:: new ( ) ,
@@ -352,23 +350,26 @@ impl<A, T> ClientBuilder<A, T>
352350where
353351 A : Address + Clone ,
354352{
355- #[ inline ]
353+ #[ must_use ]
356354 /// Set client's connection scheme
357355 pub fn scheme ( mut self , scheme : Scheme ) -> Self {
358356 self . inner . scheme = scheme;
359357 self
360358 }
361359
360+ #[ must_use]
362361 /// Set total number of simultaneous streams per connection.
363362 ///
364- /// If limit is 0, the connector uses "MAX_CONCURRENT_STREAMS" config from connection
365- /// settings.
363+ /// If limit is 0, the connector uses `MAX_CONCURRENT_STREAMS` config
364+ /// from connection settings.
365+ ///
366366 /// The default limit size is 100.
367367 pub fn max_streams ( mut self , limit : u32 ) -> Self {
368368 self . inner . max_streams = limit;
369369 self
370370 }
371371
372+ #[ must_use]
372373 /// Do not return error for frames for unknown streams.
373374 ///
374375 /// This includes pending resets, data and window update frames.
@@ -377,6 +378,7 @@ where
377378 self
378379 }
379380
381+ #[ must_use]
380382 /// Set max lifetime period for connection.
381383 ///
382384 /// Connection lifetime is max lifetime of any opened connection
@@ -388,6 +390,7 @@ where
388390 self
389391 }
390392
393+ #[ must_use]
391394 /// Sets the minimum concurrent connections.
392395 ///
393396 /// By default min connections is set to a 1.
@@ -396,6 +399,7 @@ where
396399 self
397400 }
398401
402+ #[ must_use]
399403 /// Sets the maximum concurrent connections.
400404 ///
401405 /// By default max connections is set to a 16.
@@ -447,7 +451,7 @@ where
447451 cfg : cfg. get ( ) ,
448452 config : self . inner ,
449453 } ) ,
450- waiters : Default :: default ( ) ,
454+ waiters : Rc :: default ( ) ,
451455 } )
452456 }
453457}
0 commit comments