From 4247fccb0f24aa54cf82cb18841f6f8d7ca5f5c5 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 5 Jun 2019 11:41:50 +0200 Subject: [PATCH] src/client/http_client.rs: automatically close connection in finish --- src/bin/proxmox-backup-client.rs | 1 - src/client/http_client.rs | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 5d5b85e7..7e590972 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -476,7 +476,6 @@ fn create_backup( } client.finish().wait()?; - client.force_close(); let end_time = Local.timestamp(Local::now().timestamp(), 0); let elapsed = end_time.signed_duration_since(backup_time); diff --git a/src/client/http_client.rs b/src/client/http_client.rs index 1cd8a091..c810d2f1 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -428,10 +428,6 @@ impl BackupClient { } } - pub fn force_close(mut self) { - self.canceller.take().unwrap().cancel(); - } - pub fn get(&self, path: &str, param: Option) -> impl Future { self.h2.get(path, param) } @@ -444,8 +440,16 @@ impl BackupClient { self.h2.post(path, param) } - pub fn finish(&self) -> impl Future { - self.h2.clone().post("finish", None).map(|_| ()) + pub fn finish(mut self) -> impl Future { + let canceler = self.canceller.take().unwrap(); + self.h2.clone().post("finish", None).map(move |_| { + canceler.cancel(); + () + }) + } + + pub fn force_close(mut self) { + self.canceller.take().unwrap().cancel(); } pub fn upload_config>(