Don't break TCP connection until all data is flushed

Potential fix for #14
This commit is contained in:
Aram 🍐 2021-10-16 21:12:08 -04:00
parent 479297f64d
commit 5e6cfe8955

View file

@ -179,10 +179,6 @@ async fn handle_tcp_proxy_connection(
trace!("[{}] Virtual client is ready to send data", virtual_port); trace!("[{}] Virtual client is ready to send data", virtual_port);
loop { loop {
if abort.load(Ordering::Relaxed) {
break;
}
tokio::select! { tokio::select! {
readable_result = socket.readable() => { readable_result = socket.readable() => {
match readable_result { match readable_result {
@ -234,7 +230,11 @@ async fn handle_tcp_proxy_connection(
); );
} }
Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
continue; if abort.load(Ordering::Relaxed) {
break;
} else {
continue;
}
} }
Err(e) => { Err(e) => {
error!( error!(
@ -243,7 +243,13 @@ async fn handle_tcp_proxy_connection(
); );
} }
}, },
None => continue, None => {
if abort.load(Ordering::Relaxed) {
break;
} else {
continue;
}
},
} }
} }
} }