Skip to content

Commit 411a84a

Browse files
committed
pool: Fix some connections not being properly reset
1 parent bbf24b0 commit 411a84a

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/conn/pool/mod.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -253,25 +253,6 @@ impl Pool {
253253
fn return_conn(&mut self, conn: Conn) {
254254
// NOTE: we're not in async context here, so we can't block or return NotReady
255255
// any and all cleanup work _has_ to be done in the spawned recycler
256-
257-
// fast-path for when the connection is immediately ready to be reused
258-
if conn.inner.stream.is_some()
259-
&& !conn.inner.disconnected
260-
&& !conn.expired()
261-
&& conn.inner.tx_status == TxStatus::None
262-
&& !conn.has_pending_result()
263-
&& !self.inner.close.load(atomic::Ordering::Acquire)
264-
{
265-
let mut exchange = self.inner.exchange.lock().unwrap();
266-
if exchange.available.len() < self.opts.pool_opts().active_bound() {
267-
exchange.available.push_back(conn.into());
268-
if let Some(w) = exchange.waiting.pop() {
269-
w.wake();
270-
}
271-
return;
272-
}
273-
}
274-
275256
self.send_to_recycler(conn);
276257
}
277258

@@ -492,6 +473,9 @@ mod test {
492473
.map(|conn| conn.id())
493474
.collect::<Vec<_>>();
494475

476+
// give some time to reset connections
477+
sleep(Duration::from_millis(500)).await;
478+
495479
// get_conn should work if connection is available and alive
496480
pool.get_conn().await?;
497481

0 commit comments

Comments
 (0)