Fixing a potential segfault in tag transactions (when the lru_cache was full, existing references would get dropped)
Dependencies
- [2]
AETYXHGOUsing an LruCache instead of a HashMap for loaded pages in a tag - [3]
N3X5YP7PAdding tag/txn.rs, now that the parser allows it
Change contents
- edit in libpijul/src/tag/txn.rs at line 3
use std::collections::HashMap; - edit in libpijul/src/tag/txn.rs at line 5
/// Size of the LRU cache.const CACHE_SIZE: usize = 1024; - replacement in libpijul/src/tag/txn.rs at line 32
loaded: Mutex<lru_cache::LruCache<u64, Box<[u8; crate::tag::BLOCK_SIZE]>>>,loaded: Mutex<HashMap<u64, Box<[u8; crate::tag::BLOCK_SIZE]>>>, - replacement in libpijul/src/tag/txn.rs at line 71
loaded: Mutex::new(lru_cache::LruCache::new(CACHE_SIZE)),loaded: Mutex::new(HashMap::new()), - edit in libpijul/src/tag/txn.rs at line 78
}/// Clear the cache, freeing memory.pub fn clear(&mut self) {// This function is only safe because it takes a mutable// borrow, and all references returned by the methods on// `TagTxn` return immutable borrows of `self`.self.loaded.lock().unwrap().clear()