public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] async_lru_cache: fix handling of errors in fetch
@ 2021-06-17  9:02 Stefan Reiter
  2021-06-28 11:52 ` [pbs-devel] applied: " Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Reiter @ 2021-06-17  9:02 UTC (permalink / raw)
  To: pbs-devel

The future needs to be removed from the pending map in any case, even if
it returned an error, else all upcoming calls to access this key will
always return the same error.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---

I don't think this can happen at the moment, as we only use this in parts of the
code were one returned error already causes an abort, but should still be fixed.

 src/tools/async_lru_cache.rs | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/tools/async_lru_cache.rs b/src/tools/async_lru_cache.rs
index cc385ec9..62e74fcd 100644
--- a/src/tools/async_lru_cache.rs
+++ b/src/tools/async_lru_cache.rs
@@ -65,15 +65,16 @@ impl<K: std::cmp::Eq + std::hash::Hash + Copy, V: Clone + Send + 'static> AsyncL
         };
 
         let result = result_fut.await;
-        match result {
-            Ok(Some(ref value)) if owner => {
-                // this call was the one initiating the request, put into LRU and remove from map
-                let mut maps = self.maps.lock().unwrap();
+
+        if owner {
+            // this call was the one initiating the request, put into LRU and remove from map
+            let mut maps = self.maps.lock().unwrap();
+            if let Ok(Some(ref value)) = result {
                 maps.0.insert(key, value.clone());
-                maps.1.remove(&key);
             }
-            _ => {}
+            maps.1.remove(&key);
         }
+
         result
     }
 }
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-28 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17  9:02 [pbs-devel] [PATCH proxmox-backup] async_lru_cache: fix handling of errors in fetch Stefan Reiter
2021-06-28 11:52 ` [pbs-devel] applied: " Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal