Skip to content

Commit

Permalink
iox-#27 Improve debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Feb 14, 2022
1 parent e88c1aa commit d10b138
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
51 changes: 34 additions & 17 deletions iceoryx_posh/source/roudi/port_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ void PortManager::doDiscoveryForPublisherPort(PublisherPortRouDiType& publisherP
}
else
{
// protocol error
LogWarn() << "CaPro protocol error for publisher from runtime '" << publisherPort.getRuntimeName()
<< "' and with service description '" << publisherPort.getCaProServiceDescription()
<< "'! Cannot handle CaProMessageType '" << caproMessage.m_type << "'";
errorHandler(
Error::kPORT_MANAGER__HANDLE_PUBLISHER_PORTS_INVALID_CAPRO_MESSAGE, nullptr, iox::ErrorLevel::MODERATE);
}
Expand Down Expand Up @@ -201,7 +203,9 @@ void PortManager::doDiscoveryForSubscriberPort(SubscriberPortType& subscriberPor
m_portIntrospection.reportMessage(caproMessage, subscriberPort.getUniqueID());
if (!this->sendToAllMatchingPublisherPorts(caproMessage, subscriberPort))
{
LogDebug() << "capro::SUB/UNSUB, no matching publisher!!";
LogDebug() << "capro::SUB/UNSUB, no matching publisher for subscriber from runtime '"
<< subscriberPort.getRuntimeName() << "' and with service description '"
<< caproMessage.m_serviceDescription << "'!";
capro::CaproMessage nackMessage(capro::CaproMessageType::NACK,
subscriberPort.getCaProServiceDescription());
auto returnMessage = subscriberPort.dispatchCaProMessageAndGetPossibleResponse(nackMessage);
Expand All @@ -211,7 +215,9 @@ void PortManager::doDiscoveryForSubscriberPort(SubscriberPortType& subscriberPor
}
else
{
// protocol error
LogWarn() << "CaPro protocol error for subscriber from runtime '" << subscriberPort.getRuntimeName()
<< "' and with service description '" << subscriberPort.getCaProServiceDescription()
<< "'! Cannot handle CaProMessageType '" << caproMessage.m_type << "'";
errorHandler(Error::kPORT_MANAGER__HANDLE_SUBSCRIBER_PORTS_INVALID_CAPRO_MESSAGE,
nullptr,
iox::ErrorLevel::MODERATE);
Expand Down Expand Up @@ -240,10 +246,11 @@ void PortManager::destroyClientPort(popo::ClientPortData* const clientPortData)

/// @todo iox-#27 report to port introspection

LogDebug() << "Destroy client port from runtime '" << clientPortData->m_runtimeName
<< "' and with service description '" << clientPortData->m_serviceDescription << "'";

// delete client port from list after DISCONNECT was processed
m_portPool->removeClientPort(clientPortData);

LogDebug() << "Destroyed client port";
}

void PortManager::handleClientPorts() noexcept
Expand Down Expand Up @@ -272,7 +279,9 @@ void PortManager::doDiscoveryForClientPort(popo::ClientPortRouDi& clientPort) no
/// @todo iox-#27 report to port introspection
if (!this->sendToAllMatchingServerPorts(caproMessage, clientPort))
{
LogDebug() << "capro::CONNECT/DISCONNECT, no matching server!!";
LogDebug() << "capro::CONNECT/DISCONNECT, no matching server for client from runtime '"
<< clientPort.getRuntimeName() << "' and with service description '"
<< caproMessage.m_serviceDescription << "'!";
capro::CaproMessage nackMessage(capro::CaproMessageType::NACK, clientPort.getCaProServiceDescription());
auto returnMessage = clientPort.dispatchCaProMessageAndGetPossibleResponse(nackMessage);
// No response on NACK messages
Expand All @@ -281,7 +290,9 @@ void PortManager::doDiscoveryForClientPort(popo::ClientPortRouDi& clientPort) no
}
else
{
// protocol error
LogWarn() << "CaPro protocol error for client from runtime '" << clientPort.getRuntimeName()
<< "' and with service description '" << clientPort.getCaProServiceDescription()
<< "'! Cannot handle CaProMessageType '" << caproMessage.m_type << "'";
errorHandler(
Error::kPORT_MANAGER__HANDLE_CLIENT_PORTS_INVALID_CAPRO_MESSAGE, nullptr, iox::ErrorLevel::MODERATE);
}
Expand Down Expand Up @@ -324,10 +335,11 @@ void PortManager::destroyServerPort(popo::ServerPortData* const serverPortData)

/// @todo iox-#27 report to port introspection

LogDebug() << "Destroy server port from runtime '" << serverPortData->m_runtimeName
<< "' and with service description '" << serverPortData->m_serviceDescription << "'";

// delete server port from list after STOP_OFFER was processed
m_portPool->removeServerPort(serverPortData);

LogDebug() << "Destroyed server port";
}

void PortManager::handleServerPorts() noexcept
Expand Down Expand Up @@ -362,7 +374,9 @@ void PortManager::doDiscoveryForServerPort(popo::ServerPortRouDi& serverPort) no
}
else
{
// protocol error
LogWarn() << "CaPro protocol error for server from runtime '" << serverPort.getRuntimeName()
<< "' and with service description '" << serverPort.getCaProServiceDescription()
<< "'! Cannot handle CaProMessageType '" << caproMessage.m_type << "'";
errorHandler(
Error::kPORT_MANAGER__HANDLE_SERVER_PORTS_INVALID_CAPRO_MESSAGE, nullptr, iox::ErrorLevel::MODERATE);
}
Expand All @@ -389,8 +403,9 @@ void PortManager::handleInterfaces() noexcept
// check if we have to destroy this interface port
if (interfacePortData->m_toBeDestroyed.load(std::memory_order_relaxed))
{
LogDebug() << "Destroy interface port from runtime '" << interfacePortData->m_runtimeName
<< "' and with service description '" << interfacePortData->m_serviceDescription << "'";
m_portPool->removeInterfacePort(interfacePortData);
LogDebug() << "Destroyed InterfacePortData";
}
}

Expand Down Expand Up @@ -447,8 +462,9 @@ void PortManager::handleNodes() noexcept
{
if (nodeData->m_toBeDestroyed.load(std::memory_order_relaxed))
{
LogDebug() << "Destroy NodeData from runtime '" << nodeData->m_runtimeName << "' and node name '"
<< nodeData->m_nodeName << "'";
m_portPool->removeNodeData(nodeData);
LogDebug() << "Destroyed NodeData";
}
}
}
Expand All @@ -459,8 +475,8 @@ void PortManager::handleConditionVariables() noexcept
{
if (conditionVariableData->m_toBeDestroyed.load(std::memory_order_relaxed))
{
LogDebug() << "Destroy ConditionVariableData from runtime '" << conditionVariableData->m_runtimeName << "'";
m_portPool->removeConditionVariableData(conditionVariableData);
LogDebug() << "Destroyed ConditionVariableData";
}
}
}
Expand Down Expand Up @@ -782,10 +798,10 @@ void PortManager::destroyPublisherPort(PublisherPortRouDiType::MemberType_t* con

m_portIntrospection.removePublisher(publisherPortUser);

LogDebug() << "Destroy publisher port from runtime '" << publisherPortData->m_runtimeName
<< "' and with service description '" << publisherPortData->m_serviceDescription << "'";
// delete publisher port from list after STOP_OFFER was processed
m_portPool->removePublisherPort(publisherPortData);

LogDebug() << "Destroyed publisher port";
}

void PortManager::destroySubscriberPort(SubscriberPortType::MemberType_t* const subscriberPortData) noexcept
Expand All @@ -806,10 +822,11 @@ void PortManager::destroySubscriberPort(SubscriberPortType::MemberType_t* const
});

m_portIntrospection.removeSubscriber(subscriberPortUser);

LogDebug() << "Destroy subscriber port from runtime '" << subscriberPortData->m_runtimeName
<< "' and with service description '" << subscriberPortData->m_serviceDescription << "'";
// delete subscriber port from list after UNSUB was processed
m_portPool->removeSubscriberPort(subscriberPortData);

LogDebug() << "Destroyed subscriber port";
}

runtime::IpcMessage PortManager::findService(const cxx::optional<capro::IdString_t>& service,
Expand Down
12 changes: 12 additions & 0 deletions iceoryx_posh/source/roudi/port_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ PortPool::addInterfacePort(const RuntimeName_t& runtimeName, const capro::Interf
}
else
{
LogWarn() << "Out of interface ports! Requested by runtime '" << runtimeName << "'";
errorHandler(Error::kPORT_POOL__INTERFACELIST_OVERFLOW, nullptr, ErrorLevel::MODERATE);
return cxx::error<PortPoolError>(PortPoolError::INTERFACE_PORT_LIST_FULL);
}
Expand All @@ -70,6 +71,8 @@ cxx::expected<runtime::NodeData*, PortPoolError> PortPool::addNodeData(const Run
}
else
{
LogWarn() << "Out of node data! Requested by runtime '" << runtimeName << "' and node name '" << nodeName
<< "'";
errorHandler(Error::kPORT_POOL__NODELIST_OVERFLOW, nullptr, ErrorLevel::MODERATE);
return cxx::error<PortPoolError>(PortPoolError::NODE_DATA_LIST_FULL);
}
Expand All @@ -85,6 +88,7 @@ PortPool::addConditionVariableData(const RuntimeName_t& runtimeName) noexcept
}
else
{
LogWarn() << "Out of condition variables! Requested by runtime '" << runtimeName << "'";
errorHandler(Error::kPORT_POOL__CONDITION_VARIABLE_LIST_OVERFLOW, nullptr, ErrorLevel::MODERATE);
return cxx::error<PortPoolError>(PortPoolError::CONDITION_VARIABLE_LIST_FULL);
}
Expand Down Expand Up @@ -135,6 +139,8 @@ PortPool::addPublisherPort(const capro::ServiceDescription& serviceDescription,
}
else
{
LogWarn() << "Out of publisher ports! Requested by runtime '" << runtimeName
<< "' and with service description '" << serviceDescription << "'";
errorHandler(Error::kPORT_POOL__PUBLISHERLIST_OVERFLOW, nullptr, ErrorLevel::MODERATE);
return cxx::error<PortPoolError>(PortPoolError::PUBLISHER_PORT_LIST_FULL);
}
Expand All @@ -155,6 +161,8 @@ PortPool::addSubscriberPort(const capro::ServiceDescription& serviceDescription,
}
else
{
LogWarn() << "Out of subscriber ports! Requested by runtime '" << runtimeName
<< "' and with service description '" << serviceDescription << "'";
errorHandler(Error::kPORT_POOL__SUBSCRIBERLIST_OVERFLOW, nullptr, ErrorLevel::MODERATE);
return cxx::error<PortPoolError>(PortPoolError::SUBSCRIBER_PORT_LIST_FULL);
}
Expand All @@ -179,6 +187,8 @@ PortPool::addClientPort(const capro::ServiceDescription& serviceDescription,
{
if (!m_portPoolData->m_clientPortMembers.hasFreeSpace())
{
LogWarn() << "Out of client ports! Requested by runtime '" << runtimeName << "' and with service description '"
<< serviceDescription << "'";
errorHandler(Error::kPORT_POOL__CLIENTLIST_OVERFLOW, nullptr, ErrorLevel::MODERATE);
return cxx::error<PortPoolError>(PortPoolError::CLIENT_PORT_LIST_FULL);
}
Expand All @@ -197,6 +207,8 @@ PortPool::addServerPort(const capro::ServiceDescription& serviceDescription,
{
if (!m_portPoolData->m_serverPortMembers.hasFreeSpace())
{
LogWarn() << "Out of server ports! Requested by runtime '" << runtimeName << "' and with service description '"
<< serviceDescription << "'";
errorHandler(Error::kPORT_POOL__SERVERLIST_OVERFLOW, nullptr, ErrorLevel::MODERATE);
return cxx::error<PortPoolError>(PortPoolError::SERVER_PORT_LIST_FULL);
}
Expand Down

0 comments on commit d10b138

Please sign in to comment.