TX packets are reused; need way to reset them
This commit is contained in:
parent
2fc4e6ddcf
commit
09a523fc50
2 changed files with 15 additions and 0 deletions
|
@ -271,6 +271,8 @@ impl<'a> Interaction<'a> {
|
|||
transaction: &mut Transaction,
|
||||
) -> Result<Option<Self>, Error> {
|
||||
if let Some(interaction) = Self::new(rx, transaction)? {
|
||||
tx.reset();
|
||||
|
||||
let initiated = match &interaction {
|
||||
Interaction::Read(req) => req.initiate(tx, transaction)?,
|
||||
Interaction::Write(req) => req.initiate(tx, transaction)?,
|
||||
|
|
|
@ -78,6 +78,19 @@ impl<'a> Packet<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) -> () {
|
||||
if let Direction::Tx(wb) = &mut self.data {
|
||||
wb.reset();
|
||||
wb.reserve(Packet::HDR_RESERVE).unwrap();
|
||||
|
||||
self.plain = Default::default();
|
||||
self.proto = Default::default();
|
||||
self.peer = Address::default();
|
||||
|
||||
self.proto.set_reliable();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_slice(&self) -> &[u8] {
|
||||
match &self.data {
|
||||
Direction::Rx(pb, _) => pb.as_slice(),
|
||||
|
|
Loading…
Add table
Reference in a new issue