Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calculation next_payload when more than one loop [12332] #2117

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/cpp/rtps/DataSharing/ReaderPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,18 @@ class ReaderPool : public DataSharingPayloadPool

bool ensure_reading_reference_is_in_bounds()
{
if ((next_payload_ >> 32) < (descriptor_->notified_end >> 32) &&
static_cast<uint32_t>(next_payload_) <= static_cast<uint32_t>(descriptor_->notified_end))
auto notified_end = end();
auto notified_end_high = notified_end >> 32;
auto next_payload_high = next_payload_ >> 32;
if (next_payload_high + 1 < notified_end_high ||
(next_payload_high < notified_end_high &&
static_cast<uint32_t>(next_payload_) <= static_cast<uint32_t>(notified_end)))
{
logWarning(RTPS_READER, "Writer " << writer() << " overtook reader in datasharing pool."
<< " Some changes will be missing.");

// lower part is the index, upper part is the loop counter
next_payload_ = ((next_payload_ >> 32) << 32) + static_cast<uint32_t>(descriptor_->notified_end);
next_payload_ = ((notified_end_high - 1) << 32) + static_cast<uint32_t>(notified_end);
advance(next_payload_);
return false;
}
Expand Down