[pve-devel] [PATCH proxmox-backup 2/5] restore-daemon: put blocking code into 'block_in_place'
Dominik Csapak
d.csapak at proxmox.com
Thu Jan 27 11:55:55 CET 2022
DISK_STATE.lock() and '.resolve()' can both block since they access
the disks. Putting them into a 'block_in_place' tells tokio that
this blocks an it can act accordingly
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
.../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 4c755210..0c89fd82 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -145,8 +145,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) => {
@@ -269,10 +271,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,
--
2.30.2
More information about the pve-devel
mailing list