add wait in rejector to accomodate bad TCP stacks in itelex devices
This commit is contained in:
parent
7ba68cedbd
commit
4ad5504004
@ -303,7 +303,7 @@ async fn connection_handler(
|
||||
}
|
||||
}
|
||||
|
||||
sleep(Duration::from_secs(3)).await;
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
_ = stream.shutdown().await;
|
||||
}
|
||||
|
||||
|
14
src/ports.rs
14
src/ports.rs
@ -12,10 +12,11 @@ use std::{
|
||||
use eyre::eyre;
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
use tokio::{
|
||||
io::AsyncWriteExt,
|
||||
net::TcpListener,
|
||||
sync::{watch::Receiver, Mutex},
|
||||
task::JoinHandle,
|
||||
time::Instant,
|
||||
time::{sleep, Instant},
|
||||
};
|
||||
use tracing::{debug, error, info, instrument, warn};
|
||||
|
||||
@ -353,12 +354,23 @@ impl Rejector {
|
||||
spawn(&format!("rejector for port {port}",), async move {
|
||||
let (listener, packet) = state.as_ref();
|
||||
|
||||
let packet = Arc::new(packet.clone());
|
||||
|
||||
let listener = listener.lock().await;
|
||||
|
||||
loop {
|
||||
if let Ok((mut socket, _)) = listener.accept().await {
|
||||
let packet = packet.clone();
|
||||
tokio::task::spawn(async move {
|
||||
// todo: if a client is very slow this blocks the accept loop...
|
||||
let (_, mut writer) = socket.split();
|
||||
_ = packet.send(&mut writer).await;
|
||||
|
||||
// wait two seconds before closing the connection
|
||||
// to accomodate bad itelex tpc stacks
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
_ = socket.shutdown().await;
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user