async_lru_cache: fix handling of errors in fetch
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> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
3d3769830b
commit
c48c38ab8c
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user