Skip to content

Commit

Permalink
fix: don't remove slots, just take contents
Browse files Browse the repository at this point in the history
  • Loading branch information
Devdutt Shenoi committed Sep 29, 2024
1 parent bc8de88 commit 176fe5c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rumqttc/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ impl MqttState {

for publish in second_half.iter_mut().chain(first_half) {
if let Some(publish) = publish.take() {
let tx = self.ack_waiter.remove(publish.pkid as usize);
let tx = self.ack_waiter[publish.pkid as usize].take();
let request = Request::Publish(publish);
pending.push((request, tx));
}
}

// remove and collect pending releases
for pkid in self.outgoing_rel.ones() {
let tx = self.ack_waiter.remove(pkid);
let tx = self.ack_waiter[pkid].take();
let request = Request::PubRel(PubRel::new(pkid as u16));
pending.push((request, tx));
}
Expand Down Expand Up @@ -238,7 +238,7 @@ impl MqttState {
return Err(StateError::Unsolicited(puback.pkid));
}

if let Some(tx) = self.ack_waiter.remove(puback.pkid as usize) {
if let Some(tx) = self.ack_waiter[puback.pkid as usize].take() {
// Resolve promise for QoS 1
tx.resolve();
}
Expand Down Expand Up @@ -300,7 +300,7 @@ impl MqttState {
return Err(StateError::Unsolicited(pubcomp.pkid));
}

if let Some(tx) = self.ack_waiter.remove(pubcomp.pkid as usize) {
if let Some(tx) = self.ack_waiter[pubcomp.pkid as usize].take() {
// Resolve promise for QoS 2
tx.resolve();
}
Expand Down

0 comments on commit 176fe5c

Please sign in to comment.