Skip to content

Commit

Permalink
recycler: check for closed pool in conn_return! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbeam committed Apr 13, 2023
1 parent 8c4b72a commit f23dca0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/conn/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
conn::{pool::futures::*, Conn},
error::*,
opts::{Opts, PoolOpts},
queryable::transaction::{Transaction, TxOpts, TxStatus},
queryable::transaction::{Transaction, TxOpts},
};

mod recycler;
Expand Down
8 changes: 4 additions & 4 deletions src/conn/pool/recycler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ impl Future for Recycler {
let mut close = self.inner.close.load(Ordering::Acquire);

macro_rules! conn_return {
($self:ident, $conn:ident) => {{
($self:ident, $conn:ident, $pool_is_closed: expr) => {{
let mut exchange = $self.inner.exchange.lock().unwrap();
if exchange.available.len() >= $self.pool_opts.active_bound() {
if $pool_is_closed || exchange.available.len() >= $self.pool_opts.active_bound() {
drop(exchange);
$self.discard.push($conn.close_conn().boxed());
} else {
Expand All @@ -89,7 +89,7 @@ impl Future for Recycler {
} else if $conn.inner.reset_upon_returning_to_a_pool {
$self.reset.push($conn.reset_for_pool().boxed());
} else {
conn_return!($self, $conn);
conn_return!($self, $conn, false);
}
};
}
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Future for Recycler {
loop {
match Pin::new(&mut self.reset).poll_next(cx) {
Poll::Pending | Poll::Ready(None) => break,
Poll::Ready(Some(Ok(conn))) => conn_return!(self, conn),
Poll::Ready(Some(Ok(conn))) => conn_return!(self, conn, close),
Poll::Ready(Some(Err(e))) => {
// an error during reset.
// replace with a new connection
Expand Down

0 comments on commit f23dca0

Please sign in to comment.