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

View File

@@ -531,13 +531,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;
@@ -606,7 +602,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);
}
@@ -632,9 +628,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

@@ -77,11 +77,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 {