fix(client): detect connection closes as pool tries to use
Currently, if the remote closes the connection at the same time that the pool selects it to use for a new request, the connection may actually hang. This fix will now more allow the keep-alive read to check the socket even when the `Conn` think it's busy. If the connection was closed before the request write happened, returns back an `Error::Cancel`, letting the user know they could safely retry it. Closes #1439
This commit is contained in:
		| @@ -85,7 +85,7 @@ impl<T, U> Drop for Receiver<T, U> { | ||||
|         // - Err: unreachable | ||||
|         while let Ok(Async::Ready(Some((_val, cb)))) = self.inner.poll() { | ||||
|             // maybe in future, we pass the value along with the error? | ||||
|             let _ = cb.send(Err(::Error::new_canceled())); | ||||
|             let _ = cb.send(Err(::Error::new_canceled(None))); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -243,11 +243,7 @@ where C: Connect, | ||||
|                 }, | ||||
|                 Err(_) => { | ||||
|                     error!("pooled connection was not ready, this is a hyper bug"); | ||||
|                     let err = io::Error::new( | ||||
|                         io::ErrorKind::BrokenPipe, | ||||
|                         "pool selected dead connection", | ||||
|                     ); | ||||
|                     Either::B(future::err(::Error::Io(err))) | ||||
|                     Either::B(future::err(::Error::new_canceled(None))) | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user