mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix zero-length key readback error in bulk reads
zero-length keys return a data section of None, instead of Some(<empty vec>), as the latter representation deserializes to a null pointer panic.
This commit is contained in:
parent
fd4e402d98
commit
78866199ea
3 changed files with 7 additions and 5 deletions
|
|
@ -376,9 +376,10 @@ pub struct PddbKeyRecord {
|
|||
pub age: usize,
|
||||
pub index: NonZeroU32,
|
||||
pub basis: String,
|
||||
/// If this is None, it means that the data read exceeded the bulk read limit
|
||||
/// and the record must be explicitly re-read with a non-bulk call to fetch its data.
|
||||
/// If the key is actually zero-length, a zero-length Some(Vec) is returned.
|
||||
/// If this is None, it means either that the data read exceeded the bulk read limit
|
||||
/// and the record must be explicitly re-read with a non-bulk call to fetch its data,
|
||||
/// or the key has zero length. Check the `len` field to differentiate the two.
|
||||
/// (Turns out that `rkyv` crashes when deserializing a zero-length Vec)
|
||||
pub data: Option<Vec::<u8>>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -801,7 +801,8 @@ impl Pddb {
|
|||
|
||||
/// Retrieve an entire dictionary of data in a single call. Will return data records up to but not
|
||||
/// over a total of `size_limit`. Keys that exceed the limit are still enumerated, but their
|
||||
/// data sections are `None`, instead of `Some(Vec::<u8>)`.
|
||||
/// data sections are `None`, instead of `Some(Vec::<u8>)`. Keys that are zero-length are also returned
|
||||
/// with a data section of `None`; check the `len` field of the PddbKeyRecord to determine which is which.
|
||||
/// Defaults to a size limit of up to 32k of bulk data returned, if it is not explicitly specified.
|
||||
pub fn read_dict(&self, dict: &str, basis: Option<&str>, size_limit: Option<usize>) -> Result<Vec::<PddbKeyRecord>> {
|
||||
// about the biggest we can move around in Precursor and not break heap.
|
||||
|
|
|
|||
|
|
@ -1586,7 +1586,7 @@ fn wrapped_main() -> ! {
|
|||
age: attr.age,
|
||||
index: attr.index,
|
||||
basis: attr.basis,
|
||||
data: Some(d)
|
||||
data: if d.len() > 0 { Some(d) } else { None }
|
||||
};
|
||||
state.read_total += attr.len; // commit the read length early
|
||||
let (prebuf, sbuf) = buf.split_at_mut(size_of::<u32>()*2);
|
||||
|
|
|
|||
Loading…
Reference in a new issue