This commit is contained in:
Tiago Batista Cardoso
2026-01-22 00:14:26 +01:00
parent b465608797
commit da29d67472
2 changed files with 7 additions and 16 deletions

View File

@@ -651,13 +651,9 @@ async fn quick_ping(addr: &SocketAddr, timeout_ms: u64, sd: &P2PSharedData) -> b
let mut pending = sd.pending.lock().expect("couldnt lock pending map");
pending.insert(id, tx);
}
if let Err(e) = sd.socket().send_to(&pingreq, addr) {
// remove pending on send failure
let mut pending = sd.pending.lock().expect("couldnt lock pending map");
pending.remove(&id);
eprintln!("send_to failed: {}", e);
return false;
}
sd.senders_ref()
.send_dispatch(pingreq, addr.to_string(), false, sd.messages_list());
let dur = Duration::from_millis(timeout_ms);
let res = timeout(dur, rx).await;
@@ -726,7 +722,7 @@ pub async fn get_socket_address(
for addr in addresses {
println!("trying address : {}", addr);
if quick_ping(&addr, 1000, sd).await {
if quick_ping(&addr, 10000, sd).await {
return Some(addr);
}
@@ -752,9 +748,9 @@ pub async fn get_socket_address(
// sd.messages_list().clone(),
//);
if quick_ping(&addr, 1500, sd).await {
return Some(addr);
}
//if quick_ping(&addr, 1500, sd).await {
// return Some(addr);
//}
}
None

View File

@@ -78,11 +78,6 @@ pub fn handle_recevied_message(
map.remove(&id)
};
if let Some(tx) = maybe_tx {
let _ = tx.send(Vec::new()); // ignore send error if receiver dropped
return;
}
let mut is_resp_to_server_handshake = false;
if recevied_message[4] == HELLO {