Skip to content

Commit 0f5ebb6

Browse files
committed
only bump seq if there's a message
1 parent 3ed5580 commit 0f5ebb6

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/connmgr/client.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,20 +459,23 @@ impl Connections {
459459

460460
let group = group.discard_ids();
461461

462-
for &(ckey, included) in group.removed() {
462+
// Before we do anything that might fail, let's clear the batch keys
463+
for &(ckey, _) in group.removed() {
463464
let ci = &mut nodes[ckey].value;
464-
465465
ci.batch_key = None;
466-
467-
if included {
468-
let cshared = ci.shared.as_ref().unwrap();
469-
cshared.inc_out_seq();
470-
}
471466
}
472467

473-
if let Some((addr, msg)) = to_send {
474-
return Some((count, addr, msg));
468+
let Some((addr, msg)) = to_send else {
469+
continue;
470+
};
471+
472+
for &(ckey, _) in group.removed().iter().filter(|(_, included)| *included) {
473+
let ci = &mut nodes[ckey].value;
474+
let cshared = ci.shared.as_ref().unwrap();
475+
cshared.inc_out_seq();
475476
}
477+
478+
return Some((count, addr, msg));
476479
}
477480

478481
None

src/connmgr/server.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@ impl Connections {
565565
ci.batch_key = None;
566566
}
567567

568+
let Some(msg) = msg else {
569+
continue;
570+
};
571+
568572
let mut addr = ArrayVec::<u8, 64>::new();
569573
if addr.try_extend_from_slice(group.addr()).is_err() {
570574
error!("failed to prepare addr");
@@ -577,9 +581,7 @@ impl Connections {
577581
cshared.inc_out_seq();
578582
}
579583

580-
if let Some(msg) = msg {
581-
return Some((count, addr, msg));
582-
}
584+
return Some((count, addr, msg));
583585
}
584586

585587
None

0 commit comments

Comments
 (0)