Skip to content

Commit

Permalink
fix: rename remaining threads
Browse files Browse the repository at this point in the history
  • Loading branch information
aoudiamoncef committed Oct 10, 2022
1 parent 54cf423 commit 2099e3b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
4 changes: 2 additions & 2 deletions massa-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ fn serve(api: impl Endpoints, url: &SocketAddr) -> StopHandle {
.expect("Unable to start RPC server");

let close_handle = server.close_handle();
let thread_builder = thread::Builder::new().name("massa-rpc-server".into());
let thread_builder = thread::Builder::new().name("rpc-server".into());
let join_handle = thread_builder
.spawn(|| server.wait())
.expect("failed to spawn thread : massa-rpc-server");
.expect("failed to spawn thread : rpc-server");

StopHandle {
close_handle,
Expand Down
36 changes: 20 additions & 16 deletions massa-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ use massa_storage::Storage;
use massa_time::MassaTime;
use massa_wallet::Wallet;
use parking_lot::RwLock;
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::{mem, path::PathBuf};
use std::{path::Path, process, sync::Arc};
use structopt::StructOpt;
use tokio::signal;
Expand Down Expand Up @@ -488,23 +488,27 @@ async fn launch(
use std::thread;
use std::time::Duration;
// Create a background thread which checks for deadlocks every 10s
let handler2 = thread::spawn(move || loop {
thread::sleep(Duration::from_secs(10));
let deadlocks = deadlock::check_deadlock();
println!("deadlocks check");
if deadlocks.is_empty() {
continue;
}
let thread_builder = thread::Builder::new().name("deadlock-detection".into());
thread_builder
.spawn(move || loop {
thread::sleep(Duration::from_secs(10));
let deadlocks = deadlock::check_deadlock();
println!("deadlocks check");

if deadlocks.is_empty() {
continue;
}

println!("{} deadlocks detected", deadlocks.len());
for (i, threads) in deadlocks.iter().enumerate() {
println!("Deadlock #{}", i);
for t in threads {
println!("Thread Id {:#?}", t.thread_id());
println!("{:#?}", t.backtrace());
println!("{} deadlocks detected", deadlocks.len());
for (i, threads) in deadlocks.iter().enumerate() {
println!("Deadlock #{}", i);
for t in threads {
println!("Thread Id {:#?}", t.thread_id());
println!("{:#?}", t.backtrace());
}
}
}
});
})
.expect("failed to spawn thread : deadlock-detection");
}
(
consensus_event_receiver,
Expand Down
18 changes: 11 additions & 7 deletions massa-pool-worker/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use massa_pool_exports::{PoolController, PoolManager};
use massa_storage::Storage;
use parking_lot::RwLock;
use std::sync::mpsc::RecvError;
use std::thread;
use std::{
sync::mpsc::{sync_channel, Receiver},
sync::Arc,
Expand All @@ -31,13 +32,16 @@ impl EndorsementPoolThread {
receiver: Receiver<Command>,
endorsement_pool: Arc<RwLock<EndorsementPool>>,
) -> JoinHandle<()> {
std::thread::spawn(|| {
let this = Self {
receiver,
endorsement_pool,
};
this.run()
})
let thread_builder = thread::Builder::new().name("endorsement-worker".into());
thread_builder
.spawn(|| {
let this = Self {
receiver,
endorsement_pool,
};
this.run()
})
.expect("failed to spawn thread : endorsement-worker")
}

/// Runs the thread
Expand Down

0 comments on commit 2099e3b

Please sign in to comment.