From d5e43cc1b85fff0a96f3e1ba4aea35ce0c0ca5f0 Mon Sep 17 00:00:00 2001 From: Anatoly Ikorsky Date: Mon, 29 Nov 2021 15:45:05 +0300 Subject: [PATCH] pool: Decrease the number of existing connections in Conn::drop within unwind --- src/conn/pool/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/conn/pool/mod.rs b/src/conn/pool/mod.rs index 34303845..16888050 100644 --- a/src/conn/pool/mod.rs +++ b/src/conn/pool/mod.rs @@ -285,6 +285,11 @@ impl Pool { impl Drop for Conn { fn drop(&mut self) { if std::thread::panicking() { + // Try to decrease the number of existing connections. + if let Some(pool) = self.inner.pool.take() { + pool.cancel_connection(); + } + return; }