Skip to content

Commit d559f71

Browse files
authored
Fix Latency test destruction (#5017)
Signed-off-by: Mario Dominguez <[email protected]>
1 parent 176b5c3 commit d559f71

File tree

5 files changed

+65
-46
lines changed

5 files changed

+65
-46
lines changed

test/performance/latency/LatencyTestPublisher.cpp

+26-23
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,6 @@ LatencyTestPublisher::LatencyTestPublisher()
5656

5757
LatencyTestPublisher::~LatencyTestPublisher()
5858
{
59-
// Static type endpoints shpuld have been removed for each payload iteration
60-
if (dynamic_types_)
61-
{
62-
destroy_data_endpoints();
63-
}
64-
else if (nullptr != data_writer_
65-
|| nullptr != data_reader_
66-
|| nullptr != latency_data_pub_topic_
67-
|| nullptr != latency_data_sub_topic_
68-
|| !latency_data_type_)
69-
{
70-
EPROSIMA_LOG_ERROR(LATENCYPUBLISHER, "ERROR unregistering the DATA type and/or removing the endpoints");
71-
}
72-
73-
subscriber_->delete_datareader(command_reader_);
74-
participant_->delete_subscriber(subscriber_);
75-
76-
publisher_->delete_datawriter(command_writer_);
77-
participant_->delete_publisher(publisher_);
78-
79-
participant_->delete_topic(latency_command_sub_topic_);
80-
participant_->delete_topic(latency_command_pub_topic_);
81-
8259
std::string TestCommandType("TestCommandType");
8360
participant_->unregister_type(TestCommandType);
8461

@@ -677,6 +654,32 @@ void LatencyTestPublisher::run()
677654
}
678655
}
679656

657+
void LatencyTestPublisher::destroy_user_entities()
658+
{
659+
// Static type endpoints shpuld have been removed for each payload iteration
660+
if (dynamic_types_)
661+
{
662+
destroy_data_endpoints();
663+
}
664+
else if (nullptr != data_writer_
665+
|| nullptr != data_reader_
666+
|| nullptr != latency_data_pub_topic_
667+
|| nullptr != latency_data_sub_topic_
668+
|| !latency_data_type_)
669+
{
670+
EPROSIMA_LOG_ERROR(LATENCYPUBLISHER, "ERROR unregistering the DATA type and/or removing the endpoints");
671+
}
672+
673+
subscriber_->delete_datareader(command_reader_);
674+
participant_->delete_subscriber(subscriber_);
675+
676+
publisher_->delete_datawriter(command_writer_);
677+
participant_->delete_publisher(publisher_);
678+
679+
participant_->delete_topic(latency_command_sub_topic_);
680+
participant_->delete_topic(latency_command_pub_topic_);
681+
}
682+
680683
void LatencyTestPublisher::export_csv(
681684
const std::string& data_name,
682685
const std::string& str_reliable,

test/performance/latency/LatencyTestPublisher.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ class LatencyTestPublisher
107107

108108
void run();
109109

110+
void destroy_user_entities();
111+
110112
private:
111113

112114
bool init_dynamic_types();

test/performance/latency/LatencyTestSubscriber.cpp

+26-23
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,6 @@ LatencyTestSubscriber::LatencyTestSubscriber()
4848

4949
LatencyTestSubscriber::~LatencyTestSubscriber()
5050
{
51-
// Static type endpoints should have been remove for each payload iteration
52-
if (dynamic_types_)
53-
{
54-
destroy_data_endpoints();
55-
}
56-
else if (nullptr != data_writer_
57-
|| nullptr != data_reader_
58-
|| nullptr != latency_data_pub_topic_
59-
|| nullptr != latency_data_sub_topic_
60-
|| !latency_data_type_)
61-
{
62-
EPROSIMA_LOG_ERROR(LATENCYSUBSCRIBER, "ERROR unregistering the DATA type and/or removing the endpoints");
63-
}
64-
65-
subscriber_->delete_datareader(command_reader_);
66-
participant_->delete_subscriber(subscriber_);
67-
68-
publisher_->delete_datawriter(command_writer_);
69-
participant_->delete_publisher(publisher_);
70-
71-
participant_->delete_topic(latency_command_sub_topic_);
72-
participant_->delete_topic(latency_command_pub_topic_);
73-
7451
std::string TestCommandType("TestCommandType");
7552
participant_->unregister_type(TestCommandType);
7653

@@ -635,6 +612,32 @@ void LatencyTestSubscriber::run()
635612
}
636613
}
637614

615+
void LatencyTestSubscriber::destroy_user_entities()
616+
{
617+
// Static type endpoints should have been remove for each payload iteration
618+
if (dynamic_types_)
619+
{
620+
destroy_data_endpoints();
621+
}
622+
else if (nullptr != data_writer_
623+
|| nullptr != data_reader_
624+
|| nullptr != latency_data_pub_topic_
625+
|| nullptr != latency_data_sub_topic_
626+
|| !latency_data_type_)
627+
{
628+
EPROSIMA_LOG_ERROR(LATENCYSUBSCRIBER, "ERROR unregistering the DATA type and/or removing the endpoints");
629+
}
630+
631+
subscriber_->delete_datareader(command_reader_);
632+
participant_->delete_subscriber(subscriber_);
633+
634+
publisher_->delete_datawriter(command_writer_);
635+
participant_->delete_publisher(publisher_);
636+
637+
participant_->delete_topic(latency_command_sub_topic_);
638+
participant_->delete_topic(latency_command_pub_topic_);
639+
}
640+
638641
bool LatencyTestSubscriber::test(
639642
uint32_t datasize)
640643
{

test/performance/latency/LatencyTestSubscriber.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class LatencyTestSubscriber
6868

6969
void run();
7070

71+
void destroy_user_entities();
72+
7173
bool test(
7274
uint32_t datasize);
7375

test/performance/latency/main_LatencyTest.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ int main(
504504
dynamic_types, data_sharing, data_loans, shared_memory, forced_domain, data_sizes))
505505
{
506506
latency_publisher.run();
507+
latency_publisher.destroy_user_entities();
507508
}
508509
else
509510
{
@@ -519,6 +520,7 @@ int main(
519520
xml_config_file, dynamic_types, data_sharing, data_loans, shared_memory, forced_domain, data_sizes))
520521
{
521522
latency_subscriber.run();
523+
latency_subscriber.destroy_user_entities();
522524
}
523525
else
524526
{
@@ -569,6 +571,13 @@ int main(
569571
{
570572
sub.join();
571573
}
574+
575+
for (auto& sub : latency_subscribers)
576+
{
577+
sub->destroy_user_entities();
578+
}
579+
580+
latency_publisher.destroy_user_entities();
572581
}
573582
else
574583
{

0 commit comments

Comments
 (0)