]> git.proxmox.com Git - proxmox-backup-qemu.git/commitdiff
src/restore.rs: hold reference to the runtime
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 2 Jun 2020 10:16:47 +0000 (12:16 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 2 Jun 2020 10:16:47 +0000 (12:16 +0200)
src/restore.rs

index d30fee6b52e9d2dad5fbb5ac31c3fad5607aa79c..58a362bf4d52149c81d325c7bbb641751cac5a3e 100644 (file)
@@ -1,13 +1,14 @@
 use anyhow::{bail, Error};
 use std::sync::Arc;
 
-use proxmox_backup::tools::runtime::block_on;
+use proxmox_backup::tools::runtime::{get_runtime, block_on};
 use proxmox_backup::backup::*;
 use proxmox_backup::client::{HttpClient, HttpClientOptions, BackupReader, RemoteChunkReader};
 
 use super::BackupSetup;
 
 pub(crate) struct ProxmoxRestore {
+    _runtime: Arc<tokio::runtime::Runtime>,
     pub client: Arc<BackupReader>,
     pub crypt_config: Option<Arc<CryptConfig>>,
     pub manifest: BackupManifest,
@@ -17,6 +18,10 @@ impl ProxmoxRestore {
 
     pub fn new(setup: BackupSetup) -> Result<Self, Error> {
 
+        // keep a reference to the runtime - else the runtime can be dropped
+        // and further connections fails.
+        let _runtime = get_runtime();
+
         let crypt_config = match setup.keyfile {
             None => None,
             Some(ref path) => {
@@ -55,6 +60,7 @@ impl ProxmoxRestore {
         let (client, manifest) = result?;
 
         Ok(Self {
+            _runtime,
             manifest,
             client,
             crypt_config,