Skip to content

Commit

Permalink
iox-eclipse-iceoryx#938 Destroy publisher before aborting with commun…
Browse files Browse the repository at this point in the history
…ication policy violation
  • Loading branch information
elBoberido authored and mossmaurice committed Feb 18, 2022
1 parent d686972 commit 32aa165
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,11 @@ class PortManager
void removeEntryFromServiceRegistry(const capro::ServiceDescription& service) noexcept;

template <typename T, std::enable_if_t<std::is_same<T, iox::build::OneToManyPolicy>::value>* = nullptr>
cxx::optional<RuntimeName_t>
doesViolateCommunicationPolicy(const capro::ServiceDescription& service) const noexcept;
cxx::optional<RuntimeName_t> doesViolateCommunicationPolicy(const capro::ServiceDescription& service) noexcept;

template <typename T, std::enable_if_t<std::is_same<T, iox::build::ManyToManyPolicy>::value>* = nullptr>
cxx::optional<RuntimeName_t>
doesViolateCommunicationPolicy(const capro::ServiceDescription& service IOX_MAYBE_UNUSED) const noexcept;
doesViolateCommunicationPolicy(const capro::ServiceDescription& service IOX_MAYBE_UNUSED) noexcept;

void publishServiceRegistry() const noexcept;

Expand Down
12 changes: 10 additions & 2 deletions iceoryx_posh/include/iceoryx_posh/internal/roudi/port_manager.inl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,20 +17,27 @@
#ifndef IOX_POSH_INTERNAL_ROUDI_PORT_MANAGER_INL
#define IOX_POSH_INTERNAL_ROUDI_PORT_MANAGER_INL

#include "iceoryx_posh/internal/roudi/port_manager.hpp"

namespace iox
{
namespace roudi
{
template <typename T, std::enable_if_t<std::is_same<T, iox::build::OneToManyPolicy>::value>*>
inline cxx::optional<RuntimeName_t>
PortManager::doesViolateCommunicationPolicy(const capro::ServiceDescription& service) const noexcept
PortManager::doesViolateCommunicationPolicy(const capro::ServiceDescription& service) noexcept
{
// check if the publisher is already in the list
for (auto publisherPortData : m_portPool->getPublisherPortDataList())
{
popo::PublisherPortRouDi publisherPort(publisherPortData);
if (service == publisherPort.getCaProServiceDescription())
{
if (publisherPortData->m_toBeDestroyed)
{
destroyPublisherPort(publisherPortData);
continue;
}
return cxx::make_optional<RuntimeName_t>(publisherPortData->m_runtimeName);
}
}
Expand All @@ -38,7 +46,7 @@ PortManager::doesViolateCommunicationPolicy(const capro::ServiceDescription& ser

template <typename T, std::enable_if_t<std::is_same<T, iox::build::ManyToManyPolicy>::value>*>
inline cxx::optional<RuntimeName_t>
PortManager::doesViolateCommunicationPolicy(const capro::ServiceDescription& service IOX_MAYBE_UNUSED) const noexcept
PortManager::doesViolateCommunicationPolicy(const capro::ServiceDescription& service IOX_MAYBE_UNUSED) noexcept
{
// Duplicates are allowed when using n:m policy
return cxx::nullopt;
Expand Down

0 comments on commit 32aa165

Please sign in to comment.