diff --git a/src/connect.rs b/src/connect.rs index 85100e6..6b81080 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -235,8 +235,12 @@ impl Connect for TcpStream { { TcpStream::connect(addr).map(|s| { s.set_nodelay(true).unwrap(); - s.set_read_timeout(Some(settings.read_timeout)).unwrap(); - s.set_write_timeout(Some(settings.write_timeout)).unwrap(); + if !settings.read_timeout.is_zero() { + s.set_read_timeout(Some(settings.read_timeout)).unwrap(); + } + if !settings.write_timeout.is_zero() { + s.set_write_timeout(Some(settings.write_timeout)).unwrap(); + } s }) } diff --git a/src/worker.rs b/src/worker.rs index 57e9456..bc5ff9c 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -8,6 +8,7 @@ use std::net::{TcpStream, ToSocketAddrs}; use std::thread; use std::time::{Duration, Instant, SystemTime}; +#[derive(Debug)] pub struct Worker { handler: Option>, } @@ -121,7 +122,7 @@ mod tests { #[test] fn worker_create_should_return_err_when_the_connection_open_is_failed() { - let addr = "127.0.0.1:25"; + let addr = "127.0.0.1:9"; let settings = ConnectionSettings { connect_retry_initial_delay: Duration::new(0, 1), connect_retry_max_delay: Duration::new(0, 1), @@ -130,7 +131,7 @@ mod tests { }; let (_, receiver) = unbounded(); let ret = Worker::create(addr, settings, receiver, Duration::from_millis(1), 1); - assert!(ret.is_err()) + assert!(ret.is_err(), "got: {:?}", ret) } struct Q;