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

Fix cyclic references in shared_ptr [15831] #174

Merged
merged 9 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
17 changes: 11 additions & 6 deletions .github/workflows/asan_log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@
dict({'ID': split_test[0], 'Name': split_test[2]}))

# Convert python dict to markdown table
md_table = Tomark.table(failed_tests)
print(md_table)

# Save table of failed test to GitHub action summary file
with open(SUMMARY_FILE, 'a') as file:
file.write(f'\n{md_table}')
if (failed_tests):
md_table = Tomark.table(failed_tests)
print(md_table)
# Save table of failed test to GitHub action summary file
with open(SUMMARY_FILE, 'a') as file:
file.write(f'\n{md_table}')

else:
print('NO TESTS FAILED!')
with open(SUMMARY_FILE, 'a') as file:
file.write('\nNO TESTS FAILED!')
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ jobs:
if: always()

- name: Report ASAN errors
continue-on-error: true
if: always()
run: |
echo -n "**ASAN Errors**: " >> $GITHUB_STEP_SUMMARY
Expand Down
1 change: 1 addition & 0 deletions docs/rst/api-reference/exception/exception_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Exception
/rst/api-reference/exception/corruptedfile
/rst/api-reference/exception/error
/rst/api-reference/exception/exception
/rst/api-reference/exception/inconsistency
/rst/api-reference/exception/preconditionnotmet
/rst/api-reference/exception/unsupported
10 changes: 10 additions & 0 deletions docs/rst/api-reference/exception/inconsistency.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _api_exception_inconsistency:

.. rst-class:: api-ref

Inconsistency
-------------

.. doxygenclass:: eprosima::statistics_backend::Inconsistency
:project: fastdds_statistics_backend
:members:
2 changes: 1 addition & 1 deletion docs/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ add_test(NAME documentation.code_block_check.cpp
# Check docs spelling
add_test(NAME documentation.spell_check
COMMAND
${SPHINX_EXECUTABLE} -Q -W --keep-going
${SPHINX_EXECUTABLE} -W --keep-going
-D breathe_projects.fastdds_statistics_backend=${DOXYGEN_OUTPUT_DIR}/xml
-b spelling
-d "${PROJECT_BINARY_DOCS_DIR}/doctrees"
Expand Down
30 changes: 28 additions & 2 deletions include/fastdds_statistics_backend/exception/Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,35 @@ class CorruptedFile : public Exception
const CorruptedFile& other) = default;
};

/**
* @brief Exception to signal that there has been found an inconsistency inside the database.
*/
class Inconsistency : public Exception
{

public:

using Exception::Exception;

/**
* @brief Copies the statistics_backend::Inconsistency exception into a new one
*
* @param other The original exception object to copy
*/
FASTDDS_STATISTICS_BACKEND_DllAPI Inconsistency(
const Inconsistency& other) = default;

/**
* @brief Copies the statistics_backend::Inconsistency exception into the current one
*
* @param other The original statistics_backend::Inconsistency exception to copy
* @return the current statistics_backend::Inconsistency exception after the copy
*/
FASTDDS_STATISTICS_BACKEND_DllAPI Inconsistency& operator =(
const Inconsistency& other) = default;
};

} // namespace statistics_backend
} // namespace eprosima


#endif // _EPROSIMA_FASTDDS_STATISTICS_BACKEND_EXCEPTION_EXCEPTION_HPP_

2 changes: 1 addition & 1 deletion src/cpp/StatisticsBackendData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void StatisticsBackendData::stop_monitor(

// The monitor is inactive
// NOTE: for test sake, this is not always set
if (database_->is_entity_present(monitor_id))
if (database_ && database_->is_entity_present(monitor_id))
{
database_->change_entity_status(monitor_id, false);
}
Expand Down
18 changes: 14 additions & 4 deletions src/cpp/database/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class Database
{
public:

/**
* @brief Destructor of Database.
*
* @note It requires a virtual dtor for test sake.
*/
virtual ~Database() = default;

/**
* @brief Insert a new entity into the database.
* @param entity The entity object to be inserted.
Expand Down Expand Up @@ -465,7 +472,7 @@ class Database
throw BadParameter("Endpoint locators cannot be empty");
}

/* Check that participant exits */
/* Check that participant exists */
bool participant_exists = false;
auto domain_participants = participants_.find(endpoint->participant->domain->id);
if (domain_participants != participants_.end())
Expand Down Expand Up @@ -585,11 +592,11 @@ class Database
}
}

// Change the curent locators map for the new updated one
endpoint->locators = actual_locators_map;
// Remove the current locator map as it will be filled in following loop
endpoint->locators.clear();

/* Add to x_by_y_ collections and to locators_ */
for (auto& locator_it : endpoint->locators)
for (auto& locator_it : actual_locators_map)
{
/* Check that locator exists */
if (locators_.find(locator_it.first) == locators_.end())
Expand All @@ -599,6 +606,9 @@ class Database

// Add endpoint to locator's collection
insert_ddsendpoint_to_locator(endpoint, locator_it.second);

// Add this locator to the locators map
endpoint->locators[locator_it.first] = locator_it.second;
}

/* Add endpoint to topics's collection */
Expand Down
12 changes: 6 additions & 6 deletions src/cpp/database/entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ DDSEndpoint::DDSEndpoint(
std::string endpoint_name, /* "INVALID" */
Qos endpoint_qos, /* {} */
std::string endpoint_guid, /* "|GUID UNKNOWN|" */
std::shared_ptr<DomainParticipant> endpoint_participant, /* nullptr */
std::shared_ptr<Topic> endpoint_topic /* nullptr */) noexcept
details::fragile_ptr<DomainParticipant> endpoint_participant, /* nullptr */
details::fragile_ptr<Topic> endpoint_topic /* nullptr */) noexcept
: DDSEntity(entity_kind, endpoint_name, endpoint_qos, endpoint_guid)
, participant(endpoint_participant)
, topic(endpoint_topic)
Expand Down Expand Up @@ -121,25 +121,25 @@ void Locator::clear()
}

template<>
std::map<EntityId, std::shared_ptr<DataReader>>& DomainParticipant::ddsendpoints<DataReader>()
std::map<EntityId, details::fragile_ptr<DataReader>>& DomainParticipant::ddsendpoints<DataReader>()
{
return data_readers;
}

template<>
std::map<EntityId, std::shared_ptr<DataWriter>>& DomainParticipant::ddsendpoints<DataWriter>()
std::map<EntityId, details::fragile_ptr<DataWriter>>& DomainParticipant::ddsendpoints<DataWriter>()
{
return data_writers;
}

template<>
std::map<EntityId, std::shared_ptr<DataReader>>& Topic::ddsendpoints<DataReader>()
std::map<EntityId, details::fragile_ptr<DataReader>>& Topic::ddsendpoints<DataReader>()
{
return data_readers;
}

template<>
std::map<EntityId, std::shared_ptr<DataWriter>>& Topic::ddsendpoints<DataWriter>()
std::map<EntityId, details::fragile_ptr<DataWriter>>& Topic::ddsendpoints<DataWriter>()
{
return data_writers;
}
Expand Down
Loading