Browse Source

Add more logging to thread handling

android-patches
Roman Zeyde 5 years ago
parent
commit
9c2cbfaa3d
No known key found for this signature in database GPG Key ID: 87CAE5FA46917CBB
  1. 19
      src/rpc.rs

19
src/rpc.rs

@ -563,7 +563,6 @@ impl RPC {
let stats = Arc::clone(&stats);
let garbage_sender = garbage_sender.clone();
// HACK: detach peer-handling threads
let spawned = spawn_thread("peer", move || {
info!("[{}] connected peer", addr);
let conn = Connection::new(query, stream, addr, stats, relayfee);
@ -573,15 +572,14 @@ impl RPC {
let _ = garbage_sender.send(std::thread::current().id());
});
trace!("[{}] spawned {:?}", addr, spawned.thread().id());
threads.insert(spawned.thread().id(), spawned);
while let Ok(id) = garbage_receiver.try_recv() {
let result = threads
.remove(&id)
.map(std::thread::JoinHandle::join)
.transpose();
if let Err(error) = result {
error!("Failed to join thread: {:?}", error);
if let Some(thread) = threads.remove(&id) {
trace!("[{}] joining {:?}", addr, id);
if let Err(error) = thread.join() {
error!("failed to join {:?}: {:?}", id, error);
}
}
}
}
@ -589,9 +587,10 @@ impl RPC {
for sender in senders.lock().unwrap().iter() {
let _ = sender.send(Message::Done);
}
for (_, thread) in threads {
for (id, thread) in threads {
trace!("joining {:?}", id);
if let Err(error) = thread.join() {
error!("Failed to join thread: {:?}", error);
error!("failed to join {:?}: {:?}", id, error);
}
}

Loading…
Cancel
Save