Skip to content

Commit

Permalink
Log warning upon receiver resource creation failure (#3937)
Browse files Browse the repository at this point in the history
* Log error message upon receiver resource creation failure (#3924)

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit 77a85dd)

* Rework log upon receiver resource creation failure (#3954)

* Refs #19773. Turn log error into a log warning.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #19773. Add boolean argument to `createReceiverResources`.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

---------

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

---------

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent bd53ce1 commit 54be56c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ RTPSParticipantImpl::RTPSParticipantImpl(
m_att.defaultMulticastLocatorList.clear();
}

createReceiverResources(m_att.builtin.metatrafficMulticastLocatorList, true, false);
createReceiverResources(m_att.builtin.metatrafficUnicastLocatorList, true, false);
createReceiverResources(m_att.defaultUnicastLocatorList, true, false);
createReceiverResources(m_att.defaultMulticastLocatorList, true, false);
createReceiverResources(m_att.builtin.metatrafficMulticastLocatorList, true, false, true);
createReceiverResources(m_att.builtin.metatrafficUnicastLocatorList, true, false, true);
createReceiverResources(m_att.defaultUnicastLocatorList, true, false, true);
createReceiverResources(m_att.defaultMulticastLocatorList, true, false, true);

namespace ExternalLocatorsProcessor = fastdds::rtps::ExternalLocatorsProcessor;
ExternalLocatorsProcessor::set_listening_locators(m_att.builtin.metatraffic_external_unicast_locators,
Expand Down Expand Up @@ -1567,7 +1567,7 @@ bool RTPSParticipantImpl::createAndAssociateReceiverswithEndpoint(
}

// Try creating receiver resources
if (createReceiverResources(attributes.unicastLocatorList, false, true))
if (createReceiverResources(attributes.unicastLocatorList, false, true, false))
{
break;
}
Expand Down Expand Up @@ -1596,8 +1596,8 @@ bool RTPSParticipantImpl::createAndAssociateReceiverswithEndpoint(
attributes.multicastLocatorList = m_att.defaultMulticastLocatorList;
attributes.external_unicast_locators = m_att.default_external_unicast_locators;
}
createReceiverResources(attributes.unicastLocatorList, false, true);
createReceiverResources(attributes.multicastLocatorList, false, true);
createReceiverResources(attributes.unicastLocatorList, false, true, true);
createReceiverResources(attributes.multicastLocatorList, false, true, true);
}

fastdds::rtps::ExternalLocatorsProcessor::set_listening_locators(attributes.external_unicast_locators,
Expand Down Expand Up @@ -1681,7 +1681,8 @@ void RTPSParticipantImpl::setup_external_locators(
bool RTPSParticipantImpl::createReceiverResources(
LocatorList_t& Locator_list,
bool ApplyMutation,
bool RegisterReceiver)
bool RegisterReceiver,
bool log_when_creation_fails)
{
std::vector<std::shared_ptr<ReceiverResource>> newItemsBuffer;
bool ret_val = Locator_list.empty();
Expand Down Expand Up @@ -1709,6 +1710,11 @@ bool RTPSParticipantImpl::createReceiverResources(
}
}

if (!ret && log_when_creation_fails)
{
EPROSIMA_LOG_WARNING(RTPS_PARTICIPANT, "Could not create the specified receiver resource");
}

ret_val |= !newItemsBuffer.empty();

for (auto it_buffer = newItemsBuffer.begin(); it_buffer != newItemsBuffer.end(); ++it_buffer)
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/rtps/participant/RTPSParticipantImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -981,11 +981,13 @@ class RTPSParticipantImpl
* @param Locator_list - Locator list to be used to create the ReceiverResources
* @param ApplyMutation - True if we want to create a Resource with a "similar" locator if the one we provide is unavailable
* @param RegisterReceiver - True if we want the receiver to be registered. Useful for receivers created after participant is enabled.
* @param log_when_creation_fails - True if a log warning shall be issued for each locator when a receiver resource cannot be created.
*/
bool createReceiverResources(
LocatorList_t& Locator_list,
bool ApplyMutation,
bool RegisterReceiver);
bool RegisterReceiver,
bool log_when_creation_fails);

void createSenderResources(
const LocatorList_t& locator_list);
Expand Down

0 comments on commit 54be56c

Please sign in to comment.