Skip to content

Commit

Permalink
decrement pool size when connection is released
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwhitehead authored and abonander committed Dec 18, 2020
1 parent df1b9b0 commit 07fd531
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sqlx-core/src/pool/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ impl<DB: Database> DerefMut for PoolConnection<DB> {
}

impl<DB: Database> PoolConnection<DB> {
// 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()
}
}

Expand Down Expand Up @@ -154,6 +158,10 @@ impl<'s, DB: Database> Floating<'s, Live<DB>> {
}
}

pub fn detach(self) -> DB::Connection {
self.inner.raw
}

pub fn into_idle(self) -> Floating<'s, Idle<DB>> {
Floating {
inner: self.inner.into_idle(),
Expand Down

0 comments on commit 07fd531

Please sign in to comment.