Skip to content

Commit

Permalink
Refs #19743: Add expiration check in fragile_ptr
Browse files Browse the repository at this point in the history
Signed-off-by: Carlosespicur <[email protected]>
  • Loading branch information
Carlosespicur committed Dec 3, 2024
1 parent 982e899 commit 211507e
Showing 1 changed file with 80 additions and 20 deletions.
100 changes: 80 additions & 20 deletions src/cpp/database/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4050,7 +4050,10 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
case EntityKind::USER:
for (const auto& user : host->users)
{
entities.push_back(user.second);
if (!user.second.expired())
{
entities.push_back(user.second);
}
}
break;
case EntityKind::PROCESS:
Expand Down Expand Up @@ -4085,7 +4088,10 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
case EntityKind::PROCESS:
for (const auto& process : user->processes)
{
entities.push_back(process.second);
if (!process.second.expired())
{
entities.push_back(process.second);
}
}
break;
case EntityKind::DOMAIN:
Expand Down Expand Up @@ -4117,15 +4123,21 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
}
break;
case EntityKind::USER:
entities.push_back(process->user);
if (!process->user.expired())
{
entities.push_back(process->user);
}
break;
case EntityKind::PROCESS:
entities.push_back(process);
break;
case EntityKind::PARTICIPANT:
for (const auto& participant : process->participants)
{
entities.push_back(participant.second);
if (!participant.second.expired())
{
entities.push_back(participant.second);
}
}
break;
case EntityKind::DOMAIN:
Expand Down Expand Up @@ -4155,13 +4167,19 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
case EntityKind::PARTICIPANT:
for (const auto& participant : domain->participants)
{
entities.push_back(participant.second);
if (!participant.second.expired())
{
entities.push_back(participant.second);
}
}
break;
case EntityKind::TOPIC:
for (const auto& topic : domain->topics)
{
entities.push_back(topic.second);
if (!topic.second.expired())
{
entities.push_back(topic.second);
}
}
break;
case EntityKind::HOST:
Expand Down Expand Up @@ -4206,21 +4224,30 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
}
break;
case EntityKind::DOMAIN:
entities.push_back(participant->domain);
if (!participant->domain.expired())
{
entities.push_back(participant->domain);
}
break;
case EntityKind::PARTICIPANT:
entities.push_back(participant);
break;
case EntityKind::DATAWRITER:
for (const auto& writer : participant->data_writers)
{
entities.push_back(writer.second);
if (!writer.second.expired())
{
entities.push_back(writer.second);
}
}
break;
case EntityKind::DATAREADER:
for (const auto& reader : participant->data_readers)
{
entities.push_back(reader.second);
if (!reader.second.expired())
{
entities.push_back(reader.second);
}
}
break;
case EntityKind::TOPIC:
Expand All @@ -4247,21 +4274,30 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
switch (entity_kind)
{
case EntityKind::DOMAIN:
entities.push_back(topic->domain);
if (!topic->domain.expired())
{
entities.push_back(topic->domain);
}
break;
case EntityKind::TOPIC:
entities.push_back(topic);
break;
case EntityKind::DATAWRITER:
for (const auto& writer : topic->data_writers)
{
entities.push_back(writer.second);
if (!writer.second.expired())
{
entities.push_back(writer.second);
}
}
break;
case EntityKind::DATAREADER:
for (const auto& reader : topic->data_readers)
{
entities.push_back(reader.second);
if (!reader.second.expired())
{
entities.push_back(reader.second);
}
}
break;
case EntityKind::HOST:
Expand Down Expand Up @@ -4291,18 +4327,27 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
switch (entity_kind)
{
case EntityKind::TOPIC:
entities.push_back(writer->topic);
if (!writer->topic.expired())
{
entities.push_back(writer->topic);
}
break;
case EntityKind::PARTICIPANT:
entities.push_back(writer->participant);
if (!writer->participant.expired())
{
entities.push_back(writer->participant);
}
break;
case EntityKind::DATAWRITER:
entities.push_back(writer);
break;
case EntityKind::LOCATOR:
for (const auto& locator : writer->locators)
{
entities.push_back(locator.second);
if (!locator.second.expired())
{
entities.push_back(locator.second);
}
}
break;
case EntityKind::DATAREADER:
Expand Down Expand Up @@ -4331,18 +4376,27 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
switch (entity_kind)
{
case EntityKind::TOPIC:
entities.push_back(reader->topic);
if (!reader->topic.expired())
{
entities.push_back(reader->topic);
}
break;
case EntityKind::PARTICIPANT:
entities.push_back(reader->participant);
if (!reader->participant.expired())
{
entities.push_back(reader->participant);
}
break;
case EntityKind::DATAREADER:
entities.push_back(reader);
break;
case EntityKind::LOCATOR:
for (const auto& locator : reader->locators)
{
entities.push_back(locator.second);
if (!locator.second.expired())
{
entities.push_back(locator.second);
}
}
break;
case EntityKind::DATAWRITER:
Expand Down Expand Up @@ -4373,13 +4427,19 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities_nts(
case EntityKind::DATAREADER:
for (const auto& reader : locator->data_readers)
{
entities.push_back(reader.second);
if (!reader.second.expired())
{
entities.push_back(reader.second);
}
}
break;
case EntityKind::DATAWRITER:
for (const auto& writer : locator->data_writers)
{
entities.push_back(writer.second);
if (!writer.second.expired())
{
entities.push_back(writer.second);
}
}
break;
case EntityKind::LOCATOR:
Expand Down

0 comments on commit 211507e

Please sign in to comment.