Skip to content

Commit

Permalink
Fix NextSlot when out of slots
Browse files Browse the repository at this point in the history
  • Loading branch information
dallison committed Mar 9, 2024
1 parent 4df2e72 commit 318f413
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -666,13 +666,16 @@ MessageSlot *Channel::NextSlot(MessageSlot *slot, bool reliable, int owner,
Prefix(slot)->flags |= kMessageSeen;
return slot;
}
// Going to move to another slot. Decrement refs on current slot.
IncDecRefCount(slot, reliable, -1);
slot->owners.Clear(owner);
if (slot->element.next == 0) {
// No more active slots.
// We need to hold onto the slot because when we call NextSlot again
// for the next batch of messages this slot needs still to allocated
// to the subsciber.
return nullptr;
}
// Going to move to another slot. Decrement refs on current slot.
IncDecRefCount(slot, reliable, -1);
slot->owners.Clear(owner);

slot = reinterpret_cast<MessageSlot *>(FromCCBOffset(slot->element.next));
IncDecRefCount(slot, reliable, +1);
Expand Down

0 comments on commit 318f413

Please sign in to comment.