Skip to content

Commit

Permalink
Move clear_client_state call to a single place
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Dec 6, 2024
1 parent cc022f7 commit 14949e6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions task/control-plane-agent/src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ impl DumpState {
key: [u8; 16],
seq: u32,
buf: &mut [u8],
) -> Result<Option<DumpSegment>, SpError> {
let r = self.task_dump_read_continue_inner(key, seq, buf);
if matches!(r, Ok(None) | Err(..)) {
self.clear_client_state(key);
}
r
}

pub(crate) fn task_dump_read_continue_inner(
&mut self,
key: [u8; 16],
seq: u32,
buf: &mut [u8],
) -> Result<Option<DumpSegment>, SpError> {
let Some(state) =
self.clients.iter_mut().flatten().find(|c| c.key == key)
Expand Down Expand Up @@ -202,7 +215,6 @@ impl DumpState {
if pos.offset + SEGMENT_DATA_SIZE > header.written {
if header.next == 0 {
// we're done, because there's no more dump areas
self.clear_client_state(key);
return Ok(None);
}

Expand All @@ -217,7 +229,6 @@ impl DumpState {
if header.contents != humpty::DumpContents::SingleTask.into()
|| header.nsegments != 0
{
self.clear_client_state(key);
return Ok(None);
}
// Skip the area header
Expand Down

0 comments on commit 14949e6

Please sign in to comment.