Skip to content

Commit

Permalink
Disable DataReader on destruction (#2313)
Browse files Browse the repository at this point in the history
* Refs #12870: Disable datareader on destruction

Signed-off-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>

* Refs #12870: Protect RTPSReader::setListener

Signed-off-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>
(cherry picked from commit d4de4a1)
  • Loading branch information
EduPonz authored and mergify-bot committed Nov 12, 2021
1 parent ad09169 commit 698b296
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ void DataReaderImpl::disable()

DataReaderImpl::~DataReaderImpl()
{
// Disable the datareader to prevent receiving data in the middle of deleting it
disable();
delete lifespan_timer_;
delete deadline_timer_;

Expand Down
1 change: 0 additions & 1 deletion src/cpp/fastdds/subscriber/SubscriberImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ ReturnCode_t SubscriberImpl::delete_datareader(
return ReturnCode_t::RETCODE_PRECONDITION_NOT_MET;
}

reader_impl->set_listener(nullptr);
it->second.erase(dr_it);
if (it->second.empty())
{
Expand Down
1 change: 1 addition & 0 deletions src/cpp/rtps/reader/RTPSReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ ReaderListener* RTPSReader::getListener() const
bool RTPSReader::setListener(
ReaderListener* target)
{
std::lock_guard<RecursiveTimedMutex> guard(mp_mutex);
mp_listener = target;
return true;
}
Expand Down

0 comments on commit 698b296

Please sign in to comment.