Skip to content

Commit

Permalink
Conditional internal API access to support Connext 7+ (#121)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Sorbini <[email protected]>
  • Loading branch information
asorbini authored Sep 23, 2023
1 parent d2002e1 commit afa5055
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions rmw_connextdds_common/src/ndds/dds_api_ndds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,19 +829,29 @@ rmw_connextdds_return_samples(
{
void ** data_buffer = reinterpret_cast<void **>(
RMW_Connext_MessagePtrSeq_get_contiguous_buffer(sub->data_seq()));
const DDS_Long data_len =
RMW_Connext_MessagePtrSeq_get_length(sub->data_seq());

if (!RMW_Connext_MessagePtrSeq_unloan(sub->data_seq())) {
RMW_CONNEXT_LOG_ERROR_SET("failed to unloan sample sequence")
return RMW_RET_ERROR;
}
// DDS_DataReader_return_loan_untypedI is an internal API, and
// its signature changed slightly in Connext 7.x.
#if RTI_DDS_VERSION_MAJOR < 7
const DDS_Long data_len =
RMW_Connext_MessagePtrSeq_get_length(sub->data_seq());
if (DDS_RETCODE_OK !=
DDS_DataReader_return_loan_untypedI(
sub->reader(),
data_buffer,
data_len,
sub->info_seq()))
#else
if (DDS_RETCODE_OK !=
DDS_DataReader_return_loan_untypedI(
sub->reader(),
data_buffer,
sub->info_seq()))
#endif // RTI_DDS_VERSION_MAJOR < 7
{
RMW_CONNEXT_LOG_ERROR_SET("failed to return loan to DDS reader")
return RMW_RET_ERROR;
Expand Down Expand Up @@ -891,11 +901,20 @@ rmw_connextdds_count_unread_samples(
}
if (DDS_RETCODE_OK == rc) {
unread_count += data_len;
// DDS_DataReader_return_loan_untypedI is an internal API, and
// its signature changed slightly in Connext 7.x.
#if RTI_DDS_VERSION_MAJOR < 7
rc = DDS_DataReader_return_loan_untypedI(
sub->reader(),
data_buffer,
data_len,
&info_seq);
#else
rc = DDS_DataReader_return_loan_untypedI(
sub->reader(),
data_buffer,
&info_seq);
#endif // RTI_DDS_VERSION_MAJOR < 7
if (DDS_RETCODE_OK != rc) {
RMW_CONNEXT_LOG_ERROR_SET("failed to return loan to DDS reader")
return RMW_RET_ERROR;
Expand Down

0 comments on commit afa5055

Please sign in to comment.