Skip to content

Commit

Permalink
Fix trying to get topic data that was already removed.
Browse files Browse the repository at this point in the history
Signed-off-by: Chen.Lihui <lihui.chen@sony.com>
  • Loading branch information
Chen.Lihui committed Jul 29, 2020
1 parent 8fc9ca3 commit 08632e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class SubListener : public EventListenerInterface, public eprosima::fastrtps::Su
}

void
data_taken(eprosima::fastrtps::Subscriber * sub)
updateDataCount(eprosima::fastrtps::Subscriber * sub)
{
// Make sure to call into Fast-RTPS before taking the lock to avoid an
// ABBA deadlock between internalMutex_ and mutexes inside of Fast-RTPS.
Expand Down
8 changes: 6 additions & 2 deletions rmw_fastrtps_shared_cpp/src/rmw_take.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ _take(
data.data = ros_message;
data.impl = info->type_support_impl_;
if (info->subscriber_->takeNextData(&data, &sinfo)) {
info->listener_->data_taken(info->subscriber_);
info->listener_->updateDataCount(info->subscriber_);

if (eprosima::fastrtps::rtps::ALIVE == sinfo.sampleKind) {
if (message_info) {
_assign_message_info(identifier, message_info, &sinfo);
}
*taken = true;
}
} else {
info->listener_->updateDataCount(info->subscriber_);
}

return RMW_RET_OK;
Expand Down Expand Up @@ -267,7 +269,7 @@ _take_serialized_message(
data.data = &buffer;
data.impl = nullptr; // not used when is_cdr_buffer is true
if (info->subscriber_->takeNextData(&data, &sinfo)) {
info->listener_->data_taken(info->subscriber_);
info->listener_->updateDataCount(info->subscriber_);

if (eprosima::fastrtps::rtps::ALIVE == sinfo.sampleKind) {
auto buffer_size = static_cast<size_t>(buffer.getBufferSize());
Expand All @@ -285,6 +287,8 @@ _take_serialized_message(
}
*taken = true;
}
} else {
info->listener_->updateDataCount(info->subscriber_);
}

return RMW_RET_OK;
Expand Down

0 comments on commit 08632e8

Please sign in to comment.