mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 06:38:32 -04:00
Don't break TCP connection until all data is flushed
Potential fix for #14
This commit is contained in:
parent
479297f64d
commit
5e6cfe8955
1 changed files with 12 additions and 6 deletions
16
src/main.rs
16
src/main.rs
|
@ -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;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue