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);
loop {
if abort.load(Ordering::Relaxed) {
break;
}
tokio::select! {
readable_result = socket.readable() => {
match readable_result {
@ -234,8 +230,12 @@ async fn handle_tcp_proxy_connection(
);
}
Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
if abort.load(Ordering::Relaxed) {
break;
} else {
continue;
}
}
Err(e) => {
error!(
"[{}] Failed to write to client TCP socket: {:?}",
@ -243,7 +243,13 @@ async fn handle_tcp_proxy_connection(
);
}
},
None => continue,
None => {
if abort.load(Ordering::Relaxed) {
break;
} else {
continue;
}
},
}
}
}