wip
This commit is contained in:
@@ -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");
|
let mut pending = sd.pending.lock().expect("couldnt lock pending map");
|
||||||
pending.insert(id, tx);
|
pending.insert(id, tx);
|
||||||
}
|
}
|
||||||
if let Err(e) = sd.socket().send_to(&pingreq, addr) {
|
|
||||||
// remove pending on send failure
|
sd.senders_ref()
|
||||||
let mut pending = sd.pending.lock().expect("couldnt lock pending map");
|
.send_dispatch(pingreq, addr.to_string(), false, sd.messages_list());
|
||||||
pending.remove(&id);
|
|
||||||
eprintln!("send_to failed: {}", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let dur = Duration::from_millis(timeout_ms);
|
let dur = Duration::from_millis(timeout_ms);
|
||||||
let res = timeout(dur, rx).await;
|
let res = timeout(dur, rx).await;
|
||||||
@@ -726,7 +722,7 @@ pub async fn get_socket_address(
|
|||||||
|
|
||||||
for addr in addresses {
|
for addr in addresses {
|
||||||
println!("trying address : {}", addr);
|
println!("trying address : {}", addr);
|
||||||
if quick_ping(&addr, 1000, sd).await {
|
if quick_ping(&addr, 10000, sd).await {
|
||||||
return Some(addr);
|
return Some(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,9 +748,9 @@ pub async fn get_socket_address(
|
|||||||
// sd.messages_list().clone(),
|
// sd.messages_list().clone(),
|
||||||
//);
|
//);
|
||||||
|
|
||||||
if quick_ping(&addr, 1500, sd).await {
|
//if quick_ping(&addr, 1500, sd).await {
|
||||||
return Some(addr);
|
// return Some(addr);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -78,11 +78,6 @@ pub fn handle_recevied_message(
|
|||||||
map.remove(&id)
|
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;
|
let mut is_resp_to_server_handshake = false;
|
||||||
|
|
||||||
if recevied_message[4] == HELLO {
|
if recevied_message[4] == HELLO {
|
||||||
|
|||||||
Reference in New Issue
Block a user