Skip to content

Commit

Permalink
make destroy_idle_sessions async
Browse files Browse the repository at this point in the history
  • Loading branch information
ariesdevil committed Mar 10, 2022
1 parent 9eaacad commit c124470
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions query/src/sessions/session_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl SessionManager {
let mut signal = Box::pin(signal.next());

for _index in 0..timeout_secs {
if SessionManager::destroy_idle_sessions(&active_sessions) {
if SessionManager::destroy_idle_sessions(&active_sessions).await {
return;
}

Expand Down Expand Up @@ -247,10 +247,10 @@ impl SessionManager {
.collect::<Vec<_>>()
}

fn destroy_idle_sessions(sessions: &Arc<RwLock<HashMap<String, Arc<Session>>>>) -> bool {
async fn destroy_idle_sessions(sessions: &Arc<RwLock<HashMap<String, Arc<Session>>>>) -> bool {
// Read lock does not support reentrant
// https://github.com/Amanieu/parking_lot/blob/lock_api-0.4.4/lock_api/src/rwlock.rs#L422
let active_sessions_read_guard = futures::executor::block_on(sessions.read());
let active_sessions_read_guard = sessions.read().await;

// First try to kill the idle session
active_sessions_read_guard.values().for_each(Session::kill);
Expand Down

0 comments on commit c124470

Please sign in to comment.