Skip to content

Commit

Permalink
Correctly check returned values from writer loans APIs.
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
  • Loading branch information
Mario-DL authored and MiguelCompany committed Sep 8, 2024
1 parent 76e8958 commit 3dfbcb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions rmw_fastrtps_shared_cpp/src/rmw_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ __rmw_borrow_loaned_message(
}

auto info = static_cast<CustomPublisherInfo *>(publisher->data);
if (!info->data_writer_->loan_sample(*ros_message)) {
if (eprosima::fastdds::dds::RETCODE_OK != info->data_writer_->loan_sample(*ros_message)) {
return RMW_RET_ERROR;
}

Expand All @@ -202,7 +202,7 @@ __rmw_return_loaned_message_from_publisher(
RMW_CHECK_ARGUMENT_FOR_NULL(loaned_message, RMW_RET_INVALID_ARGUMENT);

auto info = static_cast<CustomPublisherInfo *>(publisher->data);
if (!info->data_writer_->discard_loan(loaned_message)) {
if (eprosima::fastdds::dds::RETCODE_OK != info->data_writer_->discard_loan(loaned_message)) {
return RMW_RET_ERROR;
}

Expand Down
3 changes: 2 additions & 1 deletion rmw_fastrtps_shared_cpp/src/rmw_take.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ __rmw_return_loaned_message_from_subscription(
std::unique_ptr<rmw_fastrtps_shared_cpp::LoanManager::Item> item;
item = info->loan_manager_->erase_item(loaned_message);
if (item != nullptr) {
if (!info->data_reader_->return_loan(item->data_seq, item->info_seq)) {
auto ret_code = info->data_reader_->return_loan(item->data_seq, item->info_seq);
if (eprosima::fastdds::dds::RETCODE_OK != ret_code) {
RMW_SET_ERROR_MSG("Error returning loan");
return RMW_RET_ERROR;
}
Expand Down

0 comments on commit 3dfbcb2

Please sign in to comment.