Skip to content

Commit 310ba99

Browse files
committed
fix(client): cap pool idle interval to a minimum
1 parent dd63305 commit 310ba99

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/client/legacy/pool.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,14 @@ impl<T: Poolable, K: Key> PoolInner<T, K> {
433433
} else {
434434
return;
435435
};
436+
437+
// While someone might want a shorter duration, and it will be respected
438+
// at checkout time, there's no need to wake up and proactively evict
439+
// faster than this.
440+
const MIN_CHECK: Duration = Duration::from_millis(90);
441+
442+
let dur = dur.max(MIN_CHECK);
443+
436444
let (tx, rx) = oneshot::channel();
437445
self.idle_interval_ref = Some(tx);
438446

@@ -784,7 +792,7 @@ impl<T: Poolable + 'static, K: Key> IdleTask<T, K> {
784792
future::Either::Left(_) => {
785793
// pool dropped, bah-bye
786794
break;
787-
}
795+
},
788796
future::Either::Right(((), _)) => {
789797
if let Some(inner) = self.pool.upgrade() {
790798
if let Ok(mut inner) = inner.lock() {

0 commit comments

Comments
 (0)