@@ -15,6 +15,15 @@ pub struct Pool<T> {
1515    inner :  Rc < RefCell < PoolInner < T > > > , 
1616} 
1717
18+ // Before using a pooled connection, make sure the sender is not dead. 
19+ // 
20+ // This is a trait to allow the `client::pool::tests` to work for `i32`. 
21+ // 
22+ // See https://github.com/hyperium/hyper/issues/1429 
23+ pub  trait  Ready  { 
24+     fn  poll_ready ( & mut  self )  -> Poll < ( ) ,  ( ) > ; 
25+ } 
26+ 
1827struct  PoolInner < T >  { 
1928    enabled :  bool , 
2029    // These are internal Conns sitting in the event loop in the KeepAlive 
@@ -256,7 +265,7 @@ pub struct Checkout<T> {
256265    parked :  Option < relay:: Receiver < Entry < T > > > , 
257266} 
258267
259- impl < T :  Clone >  Future  for  Checkout < T >  { 
268+ impl < T :  Ready  +  Clone >  Future  for  Checkout < T >  { 
260269    type  Item  = Pooled < T > ; 
261270    type  Error  = io:: Error ; 
262271
@@ -282,21 +291,22 @@ impl<T: Clone> Future for Checkout<T> {
282291        let  mut  should_remove = false ; 
283292        let  entry = self . pool . inner . borrow_mut ( ) . idle . get_mut ( key) . and_then ( |list| { 
284293            trace ! ( "Checkout::poll key found {:?}" ,  key) ; 
285-             while  let  Some ( entry)  = list. pop ( )  { 
294+             while  let  Some ( mut   entry)  = list. pop ( )  { 
286295                match  entry. status . get ( )  { 
287296                    TimedKA :: Idle ( idle_at)  if  !expiration. expires ( idle_at)  => { 
288-                         debug ! ( "found idle connection for {:?}" ,  key) ; 
289-                         should_remove = list. is_empty ( ) ; 
290-                         return  Some ( entry) ; 
297+                         if  let  Ok ( Async :: Ready ( ( ) ) )  = entry. value . poll_ready ( )  { 
298+                             debug ! ( "found idle connection for {:?}" ,  key) ; 
299+                             should_remove = list. is_empty ( ) ; 
300+                             return  Some ( entry) ; 
301+                         } 
291302                    } , 
292-                     _ => { 
293-                         trace ! ( "Checkout::poll removing unacceptable pooled {:?}" ,  key) ; 
294-                         // every other case the Entry should just be dropped 
295-                         // 1. Idle but expired 
296-                         // 2. Busy (something else somehow took it?) 
297-                         // 3. Disabled don't reuse of course 
298-                     } 
303+                     _ => { } , 
299304                } 
305+                 trace ! ( "Checkout::poll removing unacceptable pooled {:?}" ,  key) ; 
306+                 // every other case the Entry should just be dropped 
307+                 // 1. Idle but expired 
308+                 // 2. Busy (something else somehow took it?) 
309+                 // 3. Disabled don't reuse of course 
300310            } 
301311            should_remove = true ; 
302312            None 
@@ -347,10 +357,16 @@ impl Expiration {
347357mod  tests { 
348358    use  std:: rc:: Rc ; 
349359    use  std:: time:: Duration ; 
350-     use  futures:: { Async ,  Future } ; 
360+     use  futures:: { Async ,  Future ,   Poll } ; 
351361    use  futures:: future; 
352362    use  proto:: KeepAlive ; 
353-     use  super :: Pool ; 
363+     use  super :: { Ready ,  Pool } ; 
364+ 
365+     impl  Ready  for  i32  { 
366+         fn  poll_ready ( & mut  self )  -> Poll < ( ) ,  ( ) >  { 
367+             Ok ( Async :: Ready ( ( ) ) ) 
368+         } 
369+     } 
354370
355371    #[ test]  
356372    fn  test_pool_checkout_smoke ( )  { 
0 commit comments