Skip to content

Commit

Permalink
Fixed bug in record parsing causing an infinite loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidv1992 committed Mar 13, 2024
1 parent c8a7a67 commit 56cbb03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion statime-linux/src/ke/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub async fn fetch_data(
request.write(&mut stream).await?;
stream.flush().await?;

log::trace!("Wrote message");

// we expect the to receive messages to be smaller than data_buf
let mut data_buf = vec![0; 4096];
let mut bytes_received = 0;
Expand All @@ -51,7 +53,9 @@ pub async fn fetch_data(
}
};

stream.shutdown().await?;
log::trace!("Received response");

let _ = stream.shutdown().await;

let records: Vec<_> = records.into_iter().map(|r| r.into_owned()).collect();

Expand Down
2 changes: 2 additions & 0 deletions statime-linux/src/ke/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ impl<'a> Record<'a> {
*buf = &buf[(4 + record_length)..];
Ok(res)
} else {
// Not enough data, last record
*buf = &[];
Ok(None)
}
}
Expand Down

0 comments on commit 56cbb03

Please sign in to comment.