From 07fd531a30017318a865e0f750aaa92987b21cc7 Mon Sep 17 00:00:00 2001 From: Andrew Whitehead Date: Thu, 17 Dec 2020 21:57:03 -0800 Subject: [PATCH] decrement pool size when connection is released --- sqlx-core/src/pool/connection.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sqlx-core/src/pool/connection.rs b/sqlx-core/src/pool/connection.rs index 891299ef90..9bde08ca29 100644 --- a/sqlx-core/src/pool/connection.rs +++ b/sqlx-core/src/pool/connection.rs @@ -56,9 +56,13 @@ impl DerefMut for PoolConnection { } impl PoolConnection { - // explicitly release a connection from the pool + /// Explicitly release a connection from the pool pub fn release(mut self) -> DB::Connection { - self.live.take().expect("PoolConnection double-dropped").raw + self.live + .take() + .expect("PoolConnection double-dropped") + .float(&self.pool) + .detach() } } @@ -154,6 +158,10 @@ impl<'s, DB: Database> Floating<'s, Live> { } } + pub fn detach(self) -> DB::Connection { + self.inner.raw + } + pub fn into_idle(self) -> Floating<'s, Idle> { Floating { inner: self.inner.into_idle(),