From 1f44638ec724380f06dc9c391316452283724aa2 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 2 Jan 2020 10:51:23 -0800 Subject: [PATCH] Add logs around blocking runtime shutdown --- src/blocking/client.rs | 16 ++++++++++++++-- src/blocking/wait.rs | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/blocking/client.rs b/src/blocking/client.rs index c5f1878..acc3798 100644 --- a/src/blocking/client.rs +++ b/src/blocking/client.rs @@ -582,8 +582,16 @@ struct InnerClientHandle { impl Drop for InnerClientHandle { fn drop(&mut self) { + let id = self.thread + .as_ref() + .map(|h| h.thread().id()) + .expect("thread not dropped yet"); + + trace!("closing runtime thread ({:?})", id); self.tx.take(); + trace!("signaled close for runtime thread ({:?})", id); self.thread.take().map(|h| h.join()); + trace!("closed runtime thread ({:?})", id); } } @@ -629,10 +637,14 @@ impl ClientHandle { tokio::spawn(forward(req_fut, req_tx)); } - trace!("Receiver is shutdown"); + trace!("({:?}) Receiver is shutdown", thread::current().id()); }; - rt.block_on(f) + trace!("({:?}) start runtime::block_on", thread::current().id()); + rt.block_on(f); + trace!("({:?}) end runtime::block_on", thread::current().id()); + drop(rt); + trace!("({:?}) finished", thread::current().id()); }) .map_err(crate::error::builder)?; diff --git a/src/blocking/wait.rs b/src/blocking/wait.rs index e417183..685572a 100644 --- a/src/blocking/wait.rs +++ b/src/blocking/wait.rs @@ -40,9 +40,10 @@ where return Err(Waited::TimedOut(crate::error::TimedOut)); } - log::trace!("park timeout {:?}", deadline - now); + log::trace!("({:?}) park timeout {:?}", thread::current().id(), deadline - now); thread::park_timeout(deadline - now); } else { + log::trace!("({:?}) park without timeout", thread::current().id()); thread::park(); } }