Skip to content

Commit e004c2b

Browse files
Fix Latency test destruction (#5017) (#5021)
Signed-off-by: Mario Dominguez <[email protected]> (cherry picked from commit d559f71) Co-authored-by: Mario Domínguez López <[email protected]>
1 parent 67bc44d commit e004c2b

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
@@ -54,29 +54,6 @@ LatencyTestPublisher::LatencyTestPublisher()
5454

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

@@ -675,6 +652,32 @@ void LatencyTestPublisher::run()
675652
}
676653
}
677654

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

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

@@ -633,6 +610,32 @@ void LatencyTestSubscriber::run()
633610
}
634611
}
635612

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

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)