[pve-devel] [PATCH proxmox-backup v2 2/5] restore-daemon: put blocking code into 'block_in_place'
Dominik Csapak
d.csapak at proxmox.com
Tue Apr 26 12:13:55 CEST 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 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,
--
2.30.2
More information about the pve-devel
mailing list