Skip to content

Commit 6de3fa3

Browse files
committed
Hold runtime lock during shutdown
To make sure no odd behavior is emerging when `stop`ing and `start`ing in quick succession, we now keep the runtime write lock until we're done shutting down.
1 parent b914731 commit 6de3fa3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,9 @@ impl Node {
643643
///
644644
/// After this returns most API methods will return [`Error::NotRunning`].
645645
pub fn stop(&self) -> Result<(), Error> {
646-
let runtime = self.runtime.write().unwrap().take().ok_or(Error::NotRunning)?;
646+
let mut runtime_lock = self.runtime.write().unwrap();
647+
let runtime = runtime_lock.take().ok_or(Error::NotRunning)?;
648+
647649
#[cfg(tokio_unstable)]
648650
let metrics_runtime = Arc::clone(&runtime);
649651

0 commit comments

Comments
 (0)