Skip to content

Commit

Permalink
Refs #16192. Fix deadlock when constructing ReadConditionImpl.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany committed Jan 9, 2023
1 parent 805820a commit 5666533
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,13 @@ ReadCondition* DataReaderImpl::create_readcondition(
return nullptr;
}


eprosima::fastdds::dds::detail::StateFilter current_mask{};
if (nullptr != reader_)
{
current_mask = get_last_mask_state();
}

std::lock_guard<std::recursive_mutex> _(get_conditions_mutex());

// Check if there is an associated ReadConditionImpl object already
Expand Down Expand Up @@ -1950,6 +1957,7 @@ ReadCondition* DataReaderImpl::create_readcondition(
{
// create a new one
impl = std::make_shared<detail::ReadConditionImpl>(*this, key);
impl->set_trigger_value(current_mask);
// Add the implementation object to the collection
read_conditions_.insert(impl.get());
}
Expand Down
10 changes: 0 additions & 10 deletions src/cpp/fastdds/subscriber/ReadConditionImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ class ReadConditionImpl : public std::enable_shared_from_this<ReadConditionImpl>
, value_()
, mutex_(data_reader.get_conditions_mutex())
{
try
{
auto value = data_reader_.get_last_mask_state();
std::lock_guard<std::mutex> _(value_mtx_);
value_ = value;
}
catch (std::runtime_error& e)
{
// DataReader not enabled yet
}
}

~ReadConditionImpl()
Expand Down

0 comments on commit 5666533

Please sign in to comment.