From 4d76ab91e4958b20849d285292e930b2092ecc9b Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 26 Apr 2022 12:13:55 +0200 Subject: [PATCH] restore-daemon: put blocking code into 'block_in_place' DISK_STATE.lock() and '.resolve()' can both block since they access the disks. Putting them into a 'block_in_place' makes tokio move it out in its own thread to avoid that the executor isn't able to progress any other futures in the mean time. Signed-off-by: Dominik Csapak Signed-off-by: Thomas Lamprecht --- .../src/proxmox_restore_daemon/api.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs index ef9d53b7..aeb5a71d 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs @@ -148,8 +148,10 @@ fn list( let path_str = OsStr::from_bytes(&path[..]); let param_path_buf = Path::new(path_str); - let mut disk_state = crate::DISK_STATE.lock().unwrap(); - let query_result = disk_state.resolve(param_path_buf)?; + let query_result = proxmox_async::runtime::block_in_place(move || { + let mut disk_state = crate::DISK_STATE.lock().unwrap(); + disk_state.resolve(param_path_buf) + })?; match query_result { ResolveResult::Path(vm_path) => { @@ -270,10 +272,10 @@ fn extract( let pxar = param["pxar"].as_bool().unwrap_or(true); - let query_result = { + let query_result = proxmox_async::runtime::block_in_place(move || { let mut disk_state = crate::DISK_STATE.lock().unwrap(); - disk_state.resolve(path)? - }; + disk_state.resolve(path) + })?; let vm_path = match query_result { ResolveResult::Path(vm_path) => vm_path,