From 7f3c0a062d7e81c23c13c395b5df5d8d8c702f85 Mon Sep 17 00:00:00 2001 From: jparisu Date: Thu, 22 Dec 2022 07:33:43 +0100 Subject: [PATCH 1/3] add assert in StatefulReader Signed-off-by: jparisu --- src/cpp/rtps/reader/StatefulReader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index c1232442e48..5c6cb1a9791 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -1159,6 +1159,7 @@ void StatefulReader::NotifyChanges( assert(false == aux_ch->isRead); new_data_available = true; ++total_unread_; + assert(total_unread_ <= mp_history->getHistorySize()); on_data_notify(proxGUID, aux_ch->sourceTimestamp); ++it; From 8f1d2f8f23f8cd604487fbe671383ee9fe3c788f Mon Sep 17 00:00:00 2001 From: jparisu Date: Thu, 22 Dec 2022 08:13:37 +0100 Subject: [PATCH 2/3] add assert in DataReaderImpl Signed-off-by: jparisu --- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index cfc30b84598..62d0faacd28 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -688,8 +688,11 @@ ReturnCode_t DataReaderImpl::read_or_take_next_sample( return ReturnCode_t::RETCODE_NOT_ENABLED; } + auto unread_count = get_unread_count(false); if (history_.getHistorySize() == 0) { + auto unread_count_no_history = get_unread_count(false); + assert(unread_count_no_history != unread_count || unread_count_no_history == 0); return ReturnCode_t::RETCODE_NO_DATA; } From 34d2cd98cf46fff8aadc196afaab22018a444c21 Mon Sep 17 00:00:00 2001 From: jparisu Date: Thu, 22 Dec 2022 10:30:44 +0100 Subject: [PATCH 3/3] Add new asserts Signed-off-by: jparisu --- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 18 ++++++++++-------- src/cpp/rtps/reader/StatefulReader.cpp | 9 +++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index 62d0faacd28..179fc63203b 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -688,14 +688,6 @@ ReturnCode_t DataReaderImpl::read_or_take_next_sample( return ReturnCode_t::RETCODE_NOT_ENABLED; } - auto unread_count = get_unread_count(false); - if (history_.getHistorySize() == 0) - { - auto unread_count_no_history = get_unread_count(false); - assert(unread_count_no_history != unread_count || unread_count_no_history == 0); - return ReturnCode_t::RETCODE_NO_DATA; - } - auto max_blocking_time = std::chrono::steady_clock::now() + #if HAVE_STRICT_REALTIME std::chrono::microseconds(::TimeConv::Time_t2MicroSecondsInt64(qos_.reliability().max_blocking_time)); @@ -710,6 +702,16 @@ ReturnCode_t DataReaderImpl::read_or_take_next_sample( return ReturnCode_t::RETCODE_TIMEOUT; } + auto unread_count = get_unread_count(false); + if (history_.getHistorySize() == 0) + { + auto unread_count_no_history = get_unread_count(false); + assert(unread_count_no_history != unread_count || unread_count_no_history == 0); + // assert(get_unread_count() == 0); + return ReturnCode_t::RETCODE_NO_DATA; + } + + set_read_communication_status(false); auto it = history_.lookup_available_instance(HANDLE_NIL, false); diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 5c6cb1a9791..7b43ada3eed 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -953,6 +953,10 @@ bool StatefulReader::change_removed_by_history( { --total_unread_; } + else + { + assert(false); + } } WriterProxy* proxy = wp; @@ -1426,11 +1430,16 @@ void StatefulReader::change_read_by_user( // Mark change as read if (mark_as_read && !change->isRead) { + assert(get_last_notified(change->writerGUID) >= change->sequenceNumber); change->isRead = true; if (0 < total_unread_) { --total_unread_; } + else + { + assert(false); + } } if (mark_as_read)