mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
fix(pool): add timeout to return_to_pool()
This commit is contained in:
parent
b9781c2f10
commit
8a0f1ab230
@ -13,7 +13,10 @@ use crate::error::Error;
|
||||
use super::inner::{is_beyond_max_lifetime, PoolInner};
|
||||
use crate::pool::connect::{ConnectPermit, ConnectionId};
|
||||
use crate::pool::options::PoolConnectionMetadata;
|
||||
use crate::rt;
|
||||
use std::future::Future;
|
||||
|
||||
const RETURN_TO_POOL_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
const CLOSE_ON_DROP_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
/// A connection managed by a [`Pool`][crate::pool::Pool].
|
||||
@ -149,7 +152,9 @@ impl<DB: Database> PoolConnection<DB> {
|
||||
|
||||
async move {
|
||||
let returned_to_pool = if let Some(floating) = floating {
|
||||
floating.return_to_pool().await
|
||||
rt::timeout(RETURN_TO_POOL_TIMEOUT, floating.return_to_pool())
|
||||
.await
|
||||
.unwrap_or(false)
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user