Skip to content

Commit

Permalink
Merge pull request #570 from jmlaka/con_timeout_new
Browse files Browse the repository at this point in the history
Client Association connection timeout working
  • Loading branch information
Enet4 authored Oct 13, 2024
2 parents e2162f2 + f0b9735 commit 287f84f
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions ul/src/association/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ pub enum Error {
backtrace: Backtrace,
},

/// converted SocketAddrs iterator did not yield
#[snafu(display("not a single tcp addreess provided"))]
#[non_exhaustive]
NoAddress { backtrace: Backtrace },

/// could not connect to server
Connect {
source: std::io::Error,
Expand Down Expand Up @@ -571,14 +566,10 @@ impl<'a> ClientAssociationOptions<'a> {
});

let conn_result: Result<TcpStream> = if let Some(timeout) = connection_timeout {
let mut addresses = ae_address.to_socket_addrs().context(ToAddressSnafu)?;

if addresses.by_ref().count() == 0 {
return NoAddressSnafu.fail();
}
let addresses = ae_address.to_socket_addrs().context(ToAddressSnafu)?;

let mut result: Result<TcpStream, std::io::Error> =
Result::Err(std::io::Error::from(std::io::ErrorKind::NotConnected));
Result::Err(std::io::Error::from(std::io::ErrorKind::AddrNotAvailable));

for address in addresses {
result = std::net::TcpStream::connect_timeout(&address, timeout);
Expand Down

0 comments on commit 287f84f

Please sign in to comment.