diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 945205d81f8..d4c5038e57d 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -349,10 +349,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); // Check metatraffic multicast port if (0 < m_att.builtin.metatrafficMulticastLocatorList.size() && @@ -1516,7 +1516,7 @@ bool RTPSParticipantImpl::createAndAssociateReceiverswithEndpoint( } // Try creating receiver resources - if (createReceiverResources(pend->getAttributes().unicastLocatorList, false, true)) + if (createReceiverResources(pend->getAttributes().unicastLocatorList, false, true, false)) { break; } @@ -1544,8 +1544,8 @@ bool RTPSParticipantImpl::createAndAssociateReceiverswithEndpoint( pend->getAttributes().unicastLocatorList = m_att.defaultUnicastLocatorList; pend->getAttributes().multicastLocatorList = m_att.defaultMulticastLocatorList; } - createReceiverResources(pend->getAttributes().unicastLocatorList, false, true); - createReceiverResources(pend->getAttributes().multicastLocatorList, false, true); + createReceiverResources(pend->getAttributes().unicastLocatorList, false, true, true); + createReceiverResources(pend->getAttributes().multicastLocatorList, false, true, true); } // Associate the Endpoint with ReceiverControlBlock @@ -1615,7 +1615,8 @@ bool RTPSParticipantImpl::createSendResources( bool RTPSParticipantImpl::createReceiverResources( LocatorList_t& Locator_list, bool ApplyMutation, - bool RegisterReceiver) + bool RegisterReceiver, + bool log_when_creation_fails) { std::vector> newItemsBuffer; bool ret_val = Locator_list.empty(); @@ -1643,6 +1644,11 @@ bool RTPSParticipantImpl::createReceiverResources( } } + if (!ret && log_when_creation_fails) + { + logWarning(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) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index c03b216d3d0..575f9f02923 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -966,11 +966,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);