diff options
Diffstat (limited to 'client/src/main.rs')
-rw-r--r-- | client/src/main.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/client/src/main.rs b/client/src/main.rs index e5141c7..804ab44 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -46,6 +46,9 @@ fn main() -> Result<()> { env_logger::init_from_env("LOG"); let args = Args::parse(); + #[cfg(feature = "deadlock_detection")] + std::thread::spawn(deadlock_task); + info!("connecting..."); let mut sock = TcpStream::connect(args.address)?; Packet::Connect(random()).write(&mut sock)?; @@ -56,3 +59,20 @@ fn main() -> Result<()> { Ok(()) } + +#[cfg(feature = "deadlock_detection")] +fn deadlock_task() { + let deadlocks = loop { + std::thread::sleep(std::time::Duration::from_secs(1)); + let deadlocks = parking_lot::deadlock::check_deadlock(); + if !deadlocks.is_empty() { + break deadlocks; + } + }; + for threads in &deadlocks { + for t in threads { + println!("thread {:#?}", t.thread_id()); + println!("{:#?}", t.backtrace()); + } + } +} |