desktop: remove Option for connection timeout

This commit is contained in:
sleepycatcoding 2023-07-17 19:22:45 +03:00 committed by Nathan Adams
parent ac1badc64f
commit caddd5512b
1 changed files with 8 additions and 13 deletions

View File

@ -331,7 +331,7 @@ impl NavigatorBackend for ExternalNavigatorBackend {
&mut self, &mut self,
host: String, host: String,
port: u16, port: u16,
timeout: Option<Duration>, timeout: Duration,
handle: SocketHandle, handle: SocketHandle,
receiver: Receiver<Vec<u8>>, receiver: Receiver<Vec<u8>>,
sender: Sender<SocketAction>, sender: Sender<SocketAction>,
@ -375,18 +375,13 @@ impl NavigatorBackend for ExternalNavigatorBackend {
let mut pending_write = vec![]; let mut pending_write = vec![];
let stream = if let Some(timeout) = timeout { let mut stream = match TcpStream::connect((host, port))
TcpStream::connect((host, port))
.or(async { .or(async {
Timer::after(timeout).await; Timer::after(timeout).await;
Result::<TcpStream, io::Error>::Err(io::Error::new(ErrorKind::TimedOut, "")) Result::<TcpStream, io::Error>::Err(io::Error::new(ErrorKind::TimedOut, ""))
}) })
.await .await
} else { {
TcpStream::connect((host, port)).await
};
let mut stream = match stream {
Ok(stream) => { Ok(stream) => {
sender sender
.send(SocketAction::Connect(handle, true)) .send(SocketAction::Connect(handle, true))