From d13b68f0d6e094d81832bcd6097867107fc4d852 Mon Sep 17 00:00:00 2001 From: Ryan Fowler Date: Sun, 1 Feb 2026 07:25:38 -0800 Subject: [PATCH] Fix Pool::close_blocking leaking connections on error close_blocking used try_for_each which short-circuits on the first error, leaving remaining clients' worker threads running indefinitely. Replace with a loop that closes all clients and returns the first error, matching the behavior of the async Pool::close. --- src/pool.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pool.rs b/src/pool.rs index 7bd44ce..2192c8b 100644 --- a/src/pool.rs +++ b/src/pool.rs @@ -235,10 +235,18 @@ impl Pool { /// After this method returns, all calls to `self::conn_blocking()` or /// `self::conn_mut_blocking()` will return an [`Error::Closed`] error. pub fn close_blocking(&self) -> Result<(), Error> { - self.state - .clients - .iter() - .try_for_each(|client| client.close_blocking()) + let mut first_err = None; + for client in self.state.clients.iter() { + if let Err(e) = client.close_blocking() { + if first_err.is_none() { + first_err = Some(e); + } + } + } + match first_err { + Some(e) => Err(e), + None => Ok(()), + } } fn get(&self) -> &Client {