diff --git a/tarpc/src/macros.rs b/tarpc/src/macros.rs index b17b4fd..26c02a6 100644 --- a/tarpc/src/macros.rs +++ b/tarpc/src/macros.rs @@ -316,9 +316,7 @@ mod test { #[test] fn serve_arc_server() { - serve("localhost:0", - ::std::sync::Arc::new(Server), - None) + serve("localhost:0", ::std::sync::Arc::new(Server), None) .unwrap() .shutdown(); } diff --git a/tarpc/src/protocol.rs b/tarpc/src/protocol.rs index 60a009f..6eeaa47 100644 --- a/tarpc/src/protocol.rs +++ b/tarpc/src/protocol.rs @@ -112,7 +112,9 @@ impl<'a> Drop for ConnectionHandler<'a> { } impl<'a> ConnectionHandler<'a> { - fn read(read_stream: &mut TcpStream, timeout: Option) -> bincode::serde::DeserializeResult> + fn read(read_stream: &mut TcpStream, + timeout: Option) + -> bincode::serde::DeserializeResult> where Request: serde::de::Deserialize { try!(read_stream.set_read_timeout(timeout)); @@ -155,8 +157,8 @@ impl<'a> ConnectionHandler<'a> { Err(bincode::serde::DeserializeError::IoError(ref err)) if Self::timed_out(err.kind()) => { if !self.shutdown.load(Ordering::SeqCst) { - info!("ConnectionHandler: read timed out ({:?}). Server not shutdown, so \ - retrying read.", + info!("ConnectionHandler: read timed out ({:?}). Server not \ + shutdown, so retrying read.", err); continue; } else { @@ -167,7 +169,8 @@ impl<'a> ConnectionHandler<'a> { } } Err(e) => { - warn!("ConnectionHandler: closing client connection due to {:?}", e); + warn!("ConnectionHandler: closing client connection due to {:?}", + e); return Err(e.into()); } } @@ -298,7 +301,7 @@ impl Serve for P #[derive(Debug, Clone, Serialize, Deserialize)] struct Packet { rpc_id: u64, - message: T + message: T, } struct Reader { @@ -558,7 +561,8 @@ mod test { let addr = serve_handle.local_addr().clone(); let client: Arc> = Arc::new(Client::new(addr, None).unwrap()); let thread = thread::spawn(move || serve_handle.shutdown()); - info!("force_shutdown:: rpc1: {:?}", client.rpc(&Request::Increment)); + info!("force_shutdown:: rpc1: {:?}", + client.rpc(&Request::Increment)); thread.join().unwrap(); } @@ -571,7 +575,7 @@ mod test { let client: Arc> = Arc::new(Client::new(addr, None).unwrap()); serve_handle.shutdown(); match client.rpc(&Request::Increment) { - Err(super::Error::ConnectionBroken) => {}, // success + Err(super::Error::ConnectionBroken) => {} // success otherwise => panic!("Expected Err(ConnectionBroken), got {:?}", otherwise), } let _ = client.rpc(&Request::Increment); // Test whether second failure hangs