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

Add fixes to tests for ASAN #3052

Merged
merged 1 commit into from
Oct 31, 2022
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
2 changes: 2 additions & 0 deletions src/cpp/statistics/fastdds/domain/DomainParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ ReturnCode_t DomainParticipantImpl::enable_statistics_datawriter(
auto data_writer = builtin_publisher_impl_->create_datawriter(topic, writer_impl, efd::StatusMask::all());
if (nullptr == data_writer)
{
// Remove already created Impl
delete writer_impl;
// Remove topic and type
delete_topic_and_type(use_topic_name);
logError(STATISTICS_DOMAIN_PARTICIPANT, topic_name << " DataWriter creation has failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ class DomainParticipantImpl
{
eprosima::fastrtps::rtps::RTPSDomain::removeRTPSParticipant(rtps_participant_);
}

if (participant_)
{
participant_->impl_ = nullptr;
delete participant_;
participant_ = nullptr;
}
}

public:
Expand Down Expand Up @@ -270,6 +277,7 @@ class DomainParticipantImpl
TopicProxy* proxy = new TopicProxy(topic_name, type_name, mask, topic_impl);
Topic* topic = proxy->get_topic();
topics_[topic_name] = proxy;
topics_impl_[topic_name] = topic_impl;
topic->enable();
return topic;
}
Expand Down Expand Up @@ -302,6 +310,8 @@ class DomainParticipantImpl
ReturnCode_t delete_topic(
const Topic* topic)
{
auto topic_name = topic->get_name();

if (delete_topic_mock())
{
return ReturnCode_t::RETCODE_ERROR;
Expand All @@ -314,8 +324,9 @@ class DomainParticipantImpl
{
return ReturnCode_t::RETCODE_PRECONDITION_NOT_MET;
}

std::lock_guard<std::mutex> lock(mtx_topics_);
auto it = topics_.find(topic->get_name());
auto it = topics_.find(topic_name);
if (it != topics_.end())
{
if (it->second->is_referenced())
Expand All @@ -324,6 +335,11 @@ class DomainParticipantImpl
}
delete it->second;
topics_.erase(it);

// Destroy also impl, that must exist
delete topics_impl_[topic_name];
topics_impl_.erase(topic_name);

return ReturnCode_t::RETCODE_OK;
}
return ReturnCode_t::RETCODE_ERROR;
Expand Down Expand Up @@ -694,6 +710,7 @@ class DomainParticipantImpl
mutable std::mutex mtx_subs_;
SubscriberQos default_sub_qos_;
std::map<std::string, TopicProxy*> topics_;
std::map<std::string, TopicImpl*> topics_impl_;
mutable std::mutex mtx_topics_;
std::map<std::string, TypeSupport> types_;
mutable std::mutex mtx_types_;
Expand Down
6 changes: 3 additions & 3 deletions test/mock/dds/Publisher/fastdds/dds/publisher/Publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ class Publisher : public Entity
}

bool get_datawriters(
std::vector<DataWriter*>& /*writers*/) const
std::vector<DataWriter*>& writers) const
{
return false;
return impl_->get_datawriters(writers);
}

bool has_datawriters() const
{
return false;
return impl_->has_datawriters();
}

ReturnCode_t delete_contained_entities()
Expand Down