mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix key de-allocation bug
forgot to reduce key count for the dictionary record when a key is removed.
This commit is contained in:
parent
85e48c80ed
commit
0df5f1c926
2 changed files with 2 additions and 8 deletions
|
|
@ -1010,7 +1010,7 @@ impl BasisCacheEntry {
|
||||||
free_key_index: dict.last_disk_key_index,
|
free_key_index: dict.last_disk_key_index,
|
||||||
name: dict_name,
|
name: dict_name,
|
||||||
};
|
};
|
||||||
log::trace!("syncing dict {}", name);
|
log::info!("syncing dict {} with {} keys", name, dict.key_count);
|
||||||
// log::info!("raw: {:x?}", dict_disk.deref());
|
// log::info!("raw: {:x?}", dict_disk.deref());
|
||||||
// observation: all keys to be flushed to disk will be in the KeyCacheEntry. Some may be clean,
|
// observation: all keys to be flushed to disk will be in the KeyCacheEntry. Some may be clean,
|
||||||
// but definitely all the dirty ones are in there (if they aren't, where else would they be??)
|
// but definitely all the dirty ones are in there (if they aren't, where else would they be??)
|
||||||
|
|
|
||||||
|
|
@ -621,18 +621,12 @@ impl DictCacheEntry {
|
||||||
let mut need_free_key: Option<u32> = None;
|
let mut need_free_key: Option<u32> = None;
|
||||||
if let Some(kcache) = self.keys.get_mut(&name) {
|
if let Some(kcache) = self.keys.get_mut(&name) {
|
||||||
self.clean = false;
|
self.clean = false;
|
||||||
|
self.key_count -= 1;
|
||||||
if let Some(small_index) = small_storage_index_from_key(kcache, self.index) {
|
if let Some(small_index) = small_storage_index_from_key(kcache, self.index) {
|
||||||
// handle the small pool case
|
// handle the small pool case
|
||||||
let ksp = &mut self.small_pool[small_index];
|
let ksp = &mut self.small_pool[small_index];
|
||||||
log::info!("victim: {}", name);
|
|
||||||
for s in &ksp.contents {
|
|
||||||
log::info!("before: {}", s);
|
|
||||||
}
|
|
||||||
ksp.contents.swap_remove(ksp.contents.iter().position(|s| *s == name)
|
ksp.contents.swap_remove(ksp.contents.iter().position(|s| *s == name)
|
||||||
.expect("Small pool did not contain the element we expected"));
|
.expect("Small pool did not contain the element we expected"));
|
||||||
for s in &ksp.contents {
|
|
||||||
log::info!("after: {}", s);
|
|
||||||
}
|
|
||||||
assert!(kcache.reserved <= SMALL_CAPACITY as u64, "error in small key entry size");
|
assert!(kcache.reserved <= SMALL_CAPACITY as u64, "error in small key entry size");
|
||||||
ksp.avail += kcache.reserved as u16;
|
ksp.avail += kcache.reserved as u16;
|
||||||
assert!(ksp.avail <= SMALL_CAPACITY as u16, "bookkeeping error in small pool capacity");
|
assert!(ksp.avail <= SMALL_CAPACITY as u16, "bookkeeping error in small pool capacity");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue