Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ Locator_t& RTPSParticipantImpl::applyLocatorAdaptRule(
{
metatraffic_unicast_port_ += delta;
}
else if (default_unicast_port_ == loc.port)
{
default_unicast_port_ += delta;
}
loc.port += delta;
return loc;
}
Expand Down Expand Up @@ -726,16 +730,17 @@ void RTPSParticipantImpl::setup_meta_traffic()
void RTPSParticipantImpl::setup_user_traffic()
{
// Creation of user locator and receiver resources
//If no default locators are defined we define some.
// If no default locators are defined we define some.
/* The reasoning here is the following.
If the parameters of the RTPS Participant don't hold default listening locators for the creation
of Endpoints, we make some for Unicast only.
If there is at least one listen locator of any kind, we do not create any default ones.
If there are no sending locators defined, we create default ones for the transports we implement.
*/
default_unicast_port_ = metatraffic_unicast_port_ + m_att.port.offsetd3 - m_att.port.offsetd1;
if (m_att.defaultUnicastLocatorList.empty() && m_att.defaultMulticastLocatorList.empty())
{
//Default Unicast Locators in case they have not been provided
// Default Unicast Locators in case they have not been provided
/* INSERT DEFAULT UNICAST LOCATORS FOR THE PARTICIPANT */
get_default_unicast_locators();
internal_default_locators_ = true;
Expand All @@ -746,11 +751,10 @@ void RTPSParticipantImpl::setup_user_traffic()
else
{
// Locator with port 0, calculate port.
uint32_t unicast_port = metatraffic_unicast_port_ + m_att.port.offsetd3 - m_att.port.offsetd1;
std::for_each(m_att.defaultUnicastLocatorList.begin(), m_att.defaultUnicastLocatorList.end(),
[&](Locator_t& loc)
{
m_network_Factory.fill_default_locator_port(loc, unicast_port);
m_network_Factory.fill_default_locator_port(loc, default_unicast_port_);
});
m_network_Factory.NormalizeLocators(m_att.defaultUnicastLocatorList);

Expand Down Expand Up @@ -918,7 +922,7 @@ RTPSParticipantImpl::~RTPSParticipantImpl()
delete mp_mutex;
}

template <EndpointKind_t kind, octet no_key, octet with_key>
template<EndpointKind_t kind, octet no_key, octet with_key>
bool RTPSParticipantImpl::preprocess_endpoint_attributes(
const EntityId_t& entity_id,
std::atomic<uint32_t>& id_counter,
Expand Down Expand Up @@ -1200,7 +1204,7 @@ bool RTPSParticipantImpl::create_writer(
return true;
}

template <typename Functor>
template<typename Functor>
bool RTPSParticipantImpl::create_reader(
RTPSReader** reader_out,
ReaderAttributes& param,
Expand Down Expand Up @@ -1360,8 +1364,8 @@ bool RTPSParticipantImpl::createWriter(
bool isBuiltin)
{
auto callback = [hist, listen, this]
(const GUID_t& guid, WriterAttributes& param, fastdds::rtps::FlowController* flow_controller,
IPersistenceService* persistence, bool is_reliable) -> RTPSWriter*
(const GUID_t& guid, WriterAttributes& param, fastdds::rtps::FlowController* flow_controller,
IPersistenceService* persistence, bool is_reliable) -> RTPSWriter*
{
if (is_reliable)
{
Expand Down Expand Up @@ -1409,8 +1413,8 @@ bool RTPSParticipantImpl::createWriter(
}

auto callback = [hist, listen, entityId, &payload_pool, this]
(const GUID_t& guid, WriterAttributes& param, fastdds::rtps::FlowController* flow_controller,
IPersistenceService* persistence, bool is_reliable) -> RTPSWriter*
(const GUID_t& guid, WriterAttributes& param, fastdds::rtps::FlowController* flow_controller,
IPersistenceService* persistence, bool is_reliable) -> RTPSWriter*
{
if (is_reliable)
{
Expand Down Expand Up @@ -1464,8 +1468,8 @@ bool RTPSParticipantImpl::create_writer(
}

auto callback = [hist, listen, &payload_pool, &change_pool, this]
(const GUID_t& guid, WriterAttributes& watt, fastdds::rtps::FlowController* flow_controller,
IPersistenceService* persistence, bool is_reliable) -> RTPSWriter*
(const GUID_t& guid, WriterAttributes& watt, fastdds::rtps::FlowController* flow_controller,
IPersistenceService* persistence, bool is_reliable) -> RTPSWriter*
{
if (is_reliable)
{
Expand Down Expand Up @@ -1507,8 +1511,8 @@ bool RTPSParticipantImpl::createReader(
bool enable)
{
auto callback = [hist, listen, this]
(const GUID_t& guid, ReaderAttributes& param, IPersistenceService* persistence,
bool is_reliable) -> RTPSReader*
(const GUID_t& guid, ReaderAttributes& param, IPersistenceService* persistence,
bool is_reliable) -> RTPSReader*
{
if (is_reliable)
{
Expand Down Expand Up @@ -1553,8 +1557,8 @@ bool RTPSParticipantImpl::createReader(
}

auto callback = [hist, listen, &payload_pool, this]
(const GUID_t& guid, ReaderAttributes& param, IPersistenceService* persistence,
bool is_reliable) -> RTPSReader*
(const GUID_t& guid, ReaderAttributes& param, IPersistenceService* persistence,
bool is_reliable) -> RTPSReader*
{
if (is_reliable)
{
Expand Down Expand Up @@ -2500,7 +2504,7 @@ void RTPSParticipantImpl::normalize_endpoint_locators(
EndpointAttributes& endpoint_att)
{
// Locators with port 0, calculate port.
uint32_t unicast_port = metatraffic_unicast_port_ + m_att.port.offsetd3 - m_att.port.offsetd1;
uint32_t unicast_port = default_unicast_port_;
for (Locator_t& loc : endpoint_att.unicastLocatorList)
{
m_network_Factory.fill_default_locator_port(loc, unicast_port);
Expand Down Expand Up @@ -2616,11 +2620,11 @@ uint32_t RTPSParticipantImpl::getMaxMessageSize() const
#endif // if HAVE_SECURITY

return (std::min)(
{
max_output_message_size_,
m_network_Factory.get_max_message_size_between_transports(),
max_receiver_buffer_size
});
{
max_output_message_size_,
m_network_Factory.get_max_message_size_between_transports(),
max_receiver_buffer_size
});
}

uint32_t RTPSParticipantImpl::getMaxDataSize()
Expand Down Expand Up @@ -2840,7 +2844,7 @@ std::unique_ptr<RTPSMessageGroup_t> RTPSParticipantImpl::get_send_buffer(
}

void RTPSParticipantImpl::return_send_buffer(
std::unique_ptr <RTPSMessageGroup_t>&& buffer)
std::unique_ptr<RTPSMessageGroup_t>&& buffer)
{
send_buffers_->return_buffer(std::move(buffer));
}
Expand Down Expand Up @@ -3096,8 +3100,7 @@ void RTPSParticipantImpl::get_default_unicast_locators()
void RTPSParticipantImpl::get_default_unicast_locators(
RTPSParticipantAttributes& att)
{
uint32_t unicast_port = metatraffic_unicast_port_ + att.port.offsetd3 - att.port.offsetd1;
m_network_Factory.getDefaultUnicastLocators(att.defaultUnicastLocatorList, unicast_port);
m_network_Factory.getDefaultUnicastLocators(att.defaultUnicastLocatorList, default_unicast_port_);
m_network_Factory.NormalizeLocators(att.defaultUnicastLocatorList);
}

Expand Down
12 changes: 7 additions & 5 deletions src/cpp/rtps/participant/RTPSParticipantImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ class RTPSParticipantImpl
MessageReceiver* mp_receiver; //Associated Readers/Writers inside of MessageReceiver

ReceiverControlBlock(
std::shared_ptr<ReceiverResource>& rec)
std::shared_ptr<ReceiverResource>& rec)
: Receiver(rec)
, mp_receiver(nullptr)
{
}

ReceiverControlBlock(
ReceiverControlBlock&& origen)
ReceiverControlBlock && origen)
: Receiver(origen.Receiver)
, mp_receiver(origen.mp_receiver)
{
Expand All @@ -174,7 +174,7 @@ class RTPSParticipantImpl
private:

ReceiverControlBlock(
const ReceiverControlBlock&) = delete;
const ReceiverControlBlock&) = delete;
const ReceiverControlBlock& operator =(
const ReceiverControlBlock&) = delete;

Expand Down Expand Up @@ -515,7 +515,7 @@ class RTPSParticipantImpl
std::unique_ptr<RTPSMessageGroup_t> get_send_buffer(
const std::chrono::steady_clock::time_point& max_blocking_time);
void return_send_buffer(
std::unique_ptr <RTPSMessageGroup_t>&& buffer);
std::unique_ptr<RTPSMessageGroup_t>&& buffer);

uint32_t get_domain_id() const;

Expand Down Expand Up @@ -556,6 +556,8 @@ class RTPSParticipantImpl
RTPSParticipantAttributes m_att;
//! Metatraffic unicast port used by default on this participant
uint32_t metatraffic_unicast_port_ = 0;
//! Default unicast port used by default on this participant
uint32_t default_unicast_port_ = 0;
//!Guid of the RTPSParticipant.
GUID_t m_guid;
//! String containing the RTPSParticipant Guid.
Expand Down Expand Up @@ -1141,7 +1143,7 @@ class RTPSParticipantImpl
*/
std::vector<fastdds::rtps::TransportNetmaskFilterInfo> get_netmask_filter_info() const;

template <EndpointKind_t kind, octet no_key, octet with_key>
template<EndpointKind_t kind, octet no_key, octet with_key>
static bool preprocess_endpoint_attributes(
const EntityId_t& entity_id,
std::atomic<uint32_t>& id_count,
Expand Down
3 changes: 3 additions & 0 deletions test/dds/communication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ list(APPEND TEST_DEFINITIONS
mix_zero_copy_communication
close_TCP_client
simple_data_sharing_stress
custom_metatraffic_but_empty_default
)


Expand All @@ -130,6 +131,8 @@ list(APPEND XML_CONFIGURATION_FILES
liveliness_assertion_profile.xml
liveliness_assertion.360_profile.xml
shm_communication_subscriber_dies_while_processing_message_profile.xml
custom_metatraffic_but_empty_default_pub.xml
custom_metatraffic_but_empty_default_sub.xml
)

list(APPEND PYTHON_FILES
Expand Down
2 changes: 1 addition & 1 deletion test/dds/communication/SubscriberMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main(
{
if (++arg_count >= argc)
{
std::cout << "--run-for expects a parameter" << std::endl;
std::cout << "--timeout expects a parameter" << std::endl;
return -1;
}

Expand Down
19 changes: 19 additions & 0 deletions test/dds/communication/custom_metatraffic_but_empty_default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"description" : "Test that an additional call to set_qos() does not break communication if only the defaultUnicastLocatorList is not configured",
"participants" : [
{
"kind" : "publisher",
"xmlfile" : "custom_metatraffic_but_empty_default_pub.xml",
"samples" : "60",
"seed" : "261"
},
{
"kind" : "subscriber",
"samples" : "40",
"xmlfile" : "custom_metatraffic_but_empty_default_sub.xml",
"rescan" : "5",
"seed" : "261",
"sleep_before_exec" : "2"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<profiles xmlns="http://www.eprosima.com">
<transport_descriptors>
<transport_descriptor>
<transport_id>udp_transport</transport_id>
<type>UDPv4</type>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="test_custom_meta_default_default_pub" is_default_profile="true">
<rtps>
<useBuiltinTransports>false</useBuiltinTransports>
<userTransports>
<transport_id>udp_transport</transport_id>
</userTransports>
</rtps>
</participant>

<data_writer profile_name="simple_publisher_profile" is_default_profile="true">
<qos>
<reliability>
<kind>RELIABLE</kind>
</reliability>
<data_sharing>
<kind>OFF</kind>
</data_sharing>
</qos>
</data_writer>
</profiles>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<profiles xmlns="http://www.eprosima.com">
<transport_descriptors>
<transport_descriptor>
<transport_id>udp_transport</transport_id>
<type>UDPv4</type>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="test_custom_meta_default_default_sub" is_default_profile="true">
<rtps>
<useBuiltinTransports>false</useBuiltinTransports>
<userTransports>
<transport_id>udp_transport</transport_id>
</userTransports>

<builtin>
<discovery_config>
<discoveryProtocol>SIMPLE</discoveryProtocol>
</discovery_config>

<metatrafficMulticastLocatorList>
<locator>
<udpv4>
<address>239.255.0.1</address>
<port>15150</port>
</udpv4>
</locator>
</metatrafficMulticastLocatorList>

<metatrafficUnicastLocatorList>
<locator>
<udpv4>
<port>15162</port>
</udpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>

<!-- Don't set defaultUnicastLocatorList and let Fast automatically configure it -->

</rtps>
</participant>

<data_reader profile_name="simple_subscriber_profile" is_default_profile="true">
<qos>
<reliability>
<kind>RELIABLE</kind>
</reliability>
<data_sharing>
<kind>OFF</kind>
</data_sharing>
</qos>
</data_reader>
</profiles>
Loading
Loading