Skip to content

[21745] Fix flow_controllers comparison in DomainParticipantQos equality operator #5295

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

Merged
merged 4 commits into from
Oct 7, 2024
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
11 changes: 10 additions & 1 deletion include/fastdds/dds/domain/qos/DomainParticipantQos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DomainParticipantQos
#if HAVE_SECURITY
(this->security_log_thread_ == b.security_log_thread()) &&
#endif // if HAVE_SECURITY
(this->flow_controllers_ == b.flow_controllers());
(compare_flow_controllers(b));
}

/**
Expand Down Expand Up @@ -322,6 +322,15 @@ class DomainParticipantQos
return flow_controllers_;
}

/**
* Compares the flow controllers of two DomainParticipantQos element-wise.
*
* @param qos The DomainParticipantQos to compare with.
* @return true if the flow controllers are the same, false otherwise.
*/
FASTDDS_EXPORTED_API bool compare_flow_controllers(
const DomainParticipantQos& qos) const;

/**
* Getter for FlowControllerDescriptorList
*
Expand Down
10 changes: 10 additions & 0 deletions include/fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ struct FlowControllerDescriptor
//! Thread settings for the sender thread
ThreadSettings sender_thread;

bool operator ==(
const FlowControllerDescriptor& b) const
{
return (this->name == b.name) &&
(this->scheduler == b.scheduler) &&
(this->max_bytes_per_period == b.max_bytes_per_period) &&
(this->period_ms == b.period_ms) &&
(this->sender_thread == b.sender_thread);
}

};

} // namespace rtps
Expand Down
20 changes: 20 additions & 0 deletions src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ void DomainParticipantQos::setup_transports(
utils::set_qos_from_attributes(*this, attr);
}

bool DomainParticipantQos::compare_flow_controllers(
const DomainParticipantQos& qos) const
{
const auto& lhs_flow_controllers = flow_controllers();
const auto& rhs_flow_controllers = qos.flow_controllers();

if (lhs_flow_controllers.size() != rhs_flow_controllers.size())
{
return false;
}

return std::equal(lhs_flow_controllers.begin(), lhs_flow_controllers.end(),
rhs_flow_controllers.begin(),
[](const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& a,
const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& b)
{
return *a == *b;
});
}

} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
10 changes: 9 additions & 1 deletion test/unittest/dds/participant/ParticipantTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,15 @@ void check_equivalent_qos(
ASSERT_EQ(qos_1.wire_protocol(), qos_2.wire_protocol());
ASSERT_EQ(qos_1.transport(), qos_2.transport());
ASSERT_EQ(qos_1.name(), qos_2.name());
ASSERT_EQ(qos_1.flow_controllers(), qos_2.flow_controllers());
ASSERT_EQ(qos_1.builtin_controllers_sender_thread(), qos_2.builtin_controllers_sender_thread());
ASSERT_EQ(qos_1.timed_events_thread(), qos_2.timed_events_thread());
ASSERT_EQ(qos_1.discovery_server_thread(), qos_2.discovery_server_thread());
ASSERT_EQ(qos_1.typelookup_service_thread(), qos_2.typelookup_service_thread());
#if HAVE_SECURITY
ASSERT_EQ(qos_1.security_log_thread(), qos_2.security_log_thread());
#endif // if HAVE_SECURITY

ASSERT_TRUE(qos_1.compare_flow_controllers(qos_2));
}

void check_participant_with_profile(
Expand Down
1 change: 1 addition & 0 deletions versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Forthcoming
-----------

* Allow `PERSISTENT_DURABILITY` behaving as `TRANSIENT_DURABILITY`. Fallback to `TRANSIENT_LOCAL_DURABILITY` if no persistence guid is set.
* Fix DomainParticipantQos equality operator by using the new `DomainParticipantQos::compare_flow_controllers`.

Version v3.0.0
--------------
Expand Down
Loading