TX packets are reused; need way to reset them
This commit is contained in:
parent
fb2d5a4a23
commit
1895f34439
2 changed files with 15 additions and 0 deletions
|
@ -271,6 +271,8 @@ impl<'a> Interaction<'a> {
|
||||||
transaction: &mut Transaction,
|
transaction: &mut Transaction,
|
||||||
) -> Result<Option<Self>, Error> {
|
) -> Result<Option<Self>, Error> {
|
||||||
if let Some(interaction) = Self::new(rx, transaction)? {
|
if let Some(interaction) = Self::new(rx, transaction)? {
|
||||||
|
tx.reset();
|
||||||
|
|
||||||
let initiated = match &interaction {
|
let initiated = match &interaction {
|
||||||
Interaction::Read(req) => req.initiate(tx, transaction)?,
|
Interaction::Read(req) => req.initiate(tx, transaction)?,
|
||||||
Interaction::Write(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] {
|
pub fn as_slice(&self) -> &[u8] {
|
||||||
match &self.data {
|
match &self.data {
|
||||||
Direction::Rx(pb, _) => pb.as_slice(),
|
Direction::Rx(pb, _) => pb.as_slice(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue