Skip to content

Commit 59590c0

Browse files
Fix flow_controllers comparison in DomainParticipantQos equality operator (#5295)
* Refs #21745. Compare FlowControllerDescriptor content instead of pointer address Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #21745. Update qos comparison method in tests Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #21745. Make lambda a reusable public method Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #21745. Update versions.md Signed-off-by: Juan Lopez Fernandez <[email protected]> --------- Signed-off-by: Juan Lopez Fernandez <[email protected]>
1 parent d9c18fa commit 59590c0

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

include/fastdds/dds/domain/qos/DomainParticipantQos.hpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class DomainParticipantQos
9292
#if HAVE_SECURITY
9393
(this->security_log_thread_ == b.security_log_thread()) &&
9494
#endif // if HAVE_SECURITY
95-
(this->flow_controllers_ == b.flow_controllers());
95+
(compare_flow_controllers(b));
9696
}
9797

9898
/**
@@ -322,6 +322,15 @@ class DomainParticipantQos
322322
return flow_controllers_;
323323
}
324324

325+
/**
326+
* Compares the flow controllers of two DomainParticipantQos element-wise.
327+
*
328+
* @param qos The DomainParticipantQos to compare with.
329+
* @return true if the flow controllers are the same, false otherwise.
330+
*/
331+
FASTDDS_EXPORTED_API bool compare_flow_controllers(
332+
const DomainParticipantQos& qos) const;
333+
325334
/**
326335
* Getter for FlowControllerDescriptorList
327336
*

include/fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ struct FlowControllerDescriptor
5858
//! Thread settings for the sender thread
5959
ThreadSettings sender_thread;
6060

61+
bool operator ==(
62+
const FlowControllerDescriptor& b) const
63+
{
64+
return (this->name == b.name) &&
65+
(this->scheduler == b.scheduler) &&
66+
(this->max_bytes_per_period == b.max_bytes_per_period) &&
67+
(this->period_ms == b.period_ms) &&
68+
(this->sender_thread == b.sender_thread);
69+
}
70+
6171
};
6272

6373
} // namespace rtps

src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ void DomainParticipantQos::setup_transports(
4141
utils::set_qos_from_attributes(*this, attr);
4242
}
4343

44+
bool DomainParticipantQos::compare_flow_controllers(
45+
const DomainParticipantQos& qos) const
46+
{
47+
const auto& lhs_flow_controllers = flow_controllers();
48+
const auto& rhs_flow_controllers = qos.flow_controllers();
49+
50+
if (lhs_flow_controllers.size() != rhs_flow_controllers.size())
51+
{
52+
return false;
53+
}
54+
55+
return std::equal(lhs_flow_controllers.begin(), lhs_flow_controllers.end(),
56+
rhs_flow_controllers.begin(),
57+
[](const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& a,
58+
const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& b)
59+
{
60+
return *a == *b;
61+
});
62+
}
63+
4464
} /* namespace dds */
4565
} /* namespace fastdds */
4666
} /* namespace eprosima */

test/unittest/dds/participant/ParticipantTests.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,15 @@ void check_equivalent_qos(
492492
ASSERT_EQ(qos_1.wire_protocol(), qos_2.wire_protocol());
493493
ASSERT_EQ(qos_1.transport(), qos_2.transport());
494494
ASSERT_EQ(qos_1.name(), qos_2.name());
495-
ASSERT_EQ(qos_1.flow_controllers(), qos_2.flow_controllers());
495+
ASSERT_EQ(qos_1.builtin_controllers_sender_thread(), qos_2.builtin_controllers_sender_thread());
496+
ASSERT_EQ(qos_1.timed_events_thread(), qos_2.timed_events_thread());
497+
ASSERT_EQ(qos_1.discovery_server_thread(), qos_2.discovery_server_thread());
498+
ASSERT_EQ(qos_1.typelookup_service_thread(), qos_2.typelookup_service_thread());
499+
#if HAVE_SECURITY
500+
ASSERT_EQ(qos_1.security_log_thread(), qos_2.security_log_thread());
501+
#endif // if HAVE_SECURITY
502+
503+
ASSERT_TRUE(qos_1.compare_flow_controllers(qos_2));
496504
}
497505

498506
void check_participant_with_profile(

versions.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Forthcoming
22
-----------
33

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

67
Version v3.0.0
78
--------------

0 commit comments

Comments
 (0)