ping deadlock
This commit is contained in:
@@ -90,6 +90,10 @@ impl HandshakeHistory {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_username_peerinfo_map(&self) -> Arc<Mutex<HashMap<String, PeerInfo>>> {
|
||||
self.username_k_peerinfo_v.clone()
|
||||
}
|
||||
|
||||
pub fn add_new_handshake(&self, hash: VerifyingKey, username: String, ip: SocketAddr) {
|
||||
let peerinfo = PeerInfo {
|
||||
username: username.clone(),
|
||||
@@ -112,14 +116,11 @@ pub fn update_handshake(
|
||||
let map_for_thread = username_k_peerinfo_v.clone();
|
||||
let handle = thread::spawn(move || {
|
||||
loop {
|
||||
println!("loop boucle");
|
||||
let guard = map_for_thread.lock().unwrap();
|
||||
println!("len:{}", guard.len());
|
||||
for (peer, peerinfo) in guard.iter() {
|
||||
let id = generate_id();
|
||||
let mut map = messages_list.lock().unwrap();
|
||||
map.insert(id, EventType::Ping);
|
||||
drop(map);
|
||||
let pingrequest = construct_message(PING, Vec::new(), id, &crypto_pair);
|
||||
if let Some(ping) = pingrequest {
|
||||
senders.add_message_to_retry_queue(
|
||||
@@ -133,10 +134,10 @@ pub fn update_handshake(
|
||||
false,
|
||||
messages_list.clone(),
|
||||
);
|
||||
println!("ping envoye a {}", peer);
|
||||
}
|
||||
}
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
drop(guard);
|
||||
thread::sleep(Duration::from_secs(240));
|
||||
}
|
||||
});
|
||||
Worker::spawn(handle, crate::threads_handling::WorkerType::PING)
|
||||
|
||||
Reference in New Issue
Block a user