Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17941] Fix regression introduced by #3396 #3418

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,10 +1203,7 @@ void DataWriterImpl::InnerDataWriterListener::onWriterMatched(
listener->on_publication_matched(data_writer_->user_datawriter_, callback_status);
}
}
else
{
data_writer_->user_datawriter_->get_statuscondition().get_impl()->set_status(notify_status, true);
}
data_writer_->user_datawriter_->get_statuscondition().get_impl()->set_status(notify_status, true);
}

void DataWriterImpl::InnerDataWriterListener::on_offered_incompatible_qos(
Expand Down
5 changes: 1 addition & 4 deletions src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,7 @@ void DataReaderImpl::InnerDataReaderListener::onReaderMatched(
listener->on_subscription_matched(data_reader_->user_datareader_, callback_status);
}
}
else
{
data_reader_->user_datareader_->get_statuscondition().get_impl()->set_status(notify_status, true);
}
data_reader_->user_datareader_->get_statuscondition().get_impl()->set_status(notify_status, true);
}

void DataReaderImpl::InnerDataReaderListener::on_liveliness_changed(
Expand Down
92 changes: 92 additions & 0 deletions test/blackbox/common/DDSBlackboxTestsDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1511,3 +1511,95 @@ TEST(DDSDiscovery, CheckIncorrectWriterDurabilityQosXmlStaticDiscoveryFile)
DomainParticipantFactory* factory = DomainParticipantFactory::get_instance();
ASSERT_EQ(factory->check_xml_static_discovery(file), ReturnCode_t::RETCODE_ERROR);
}

/**
* Regression test for redmine issue #17919
*/
static void test_DDSDiscovery_WaitSetMatchedStatus(
bool with_listener)
{
using namespace eprosima;

auto factory = fastdds::dds::DomainParticipantFactory::get_instance();
fastdds::dds::DomainParticipantQos pqos;
factory->get_default_participant_qos(pqos);
uint32_t ignore_flags =
fastrtps::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_HOST |
fastrtps::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_PROCESS;
pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags =
static_cast<fastrtps::rtps::ParticipantFilteringFlags>(ignore_flags);

fastdds::dds::DomainParticipantListener listener;
auto listener_to_use = with_listener ? &listener : nullptr;

fastdds::dds::DomainParticipant* participant = factory->create_participant(0, pqos, listener_to_use);
ASSERT_NE(participant, nullptr);

fastdds::dds::TypeSupport type(new HelloWorldPubSubType());
EXPECT_EQ(type.register_type(participant), ReturnCode_t::RETCODE_OK);

auto topic = participant->create_topic(TEST_TOPIC_NAME, type->getName(), fastdds::dds::TOPIC_QOS_DEFAULT);
ASSERT_NE(topic, nullptr);

auto publisher = participant->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT);
ASSERT_NE(publisher, nullptr);

auto data_writer = publisher->create_datawriter(topic, fastdds::dds::DATAWRITER_QOS_DEFAULT);
ASSERT_NE(data_writer, nullptr);

auto thread_run = [data_writer]()
{
fastdds::dds::WaitSet wait_set;
fastdds::dds::ConditionSeq triggered_conditions;

fastdds::dds::StatusCondition& condition = data_writer->get_statuscondition();
condition.set_enabled_statuses(fastdds::dds::StatusMask::publication_matched());
wait_set.attach_condition(condition);

fastdds::dds::PublicationMatchedStatus matched_status{};
while (1 > matched_status.current_count)
{
ReturnCode_t ret_code = wait_set.wait(triggered_conditions, fastrtps::c_TimeInfinite);
if (ReturnCode_t::RETCODE_OK != ret_code)
{
continue;
}

for (fastdds::dds::Condition* cond : triggered_conditions)
{
fastdds::dds::StatusCondition* status_cond = dynamic_cast<fastdds::dds::StatusCondition*>(cond);
if (nullptr != status_cond)
{
EXPECT_EQ(status_cond, &condition);
fastdds::dds::Entity* entity = status_cond->get_entity();
EXPECT_EQ(entity, data_writer);
fastdds::dds::StatusMask changed_statuses = entity->get_status_changes();

if (changed_statuses.is_active(fastdds::dds::StatusMask::publication_matched()))
{
data_writer->get_publication_matched_status(matched_status);
}
}
}
}
};

std::thread waiting_thread(thread_run);

auto subscriber = participant->create_subscriber(fastdds::dds::SUBSCRIBER_QOS_DEFAULT);
ASSERT_NE(subscriber, nullptr);

auto data_reader = subscriber->create_datareader(topic, fastdds::dds::DATAREADER_QOS_DEFAULT);
ASSERT_NE(data_reader, nullptr);

waiting_thread.join();

participant->delete_contained_entities();
factory->delete_participant(participant);
}

TEST(DDSDiscovery, WaitSetMatchedStatus)
{
test_DDSDiscovery_WaitSetMatchedStatus(false);
test_DDSDiscovery_WaitSetMatchedStatus(true);
}