Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21913] DomainParticipant creation fails if SHM MaxMessageSize is lower than minimum #5342

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 29 additions & 2 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,25 @@ static bool get_unique_flows_parameters(
return true;
}

/**
* @brief This method checks if the maximum message size is equal or higher than the PDP package size.
* @return true if the maximum message size is equal or higher than the PDP package size, false otherwise.
*/
static bool is_max_message_size_big_enough(
const uint32_t max_message_size)
{
constexpr uint32_t info_dst_message_length = 16;
constexpr uint32_t info_ts_message_length = 12;
uint32_t statistics_message_length = 0;
#ifdef FASTDDS_STATISTICS
statistics_message_length = eprosima::fastdds::statistics::rtps::statistics_submessage_length;
#endif // FASTDDS_STATISTICS

return max_message_size >=
(RTPSMESSAGE_HEADER_SIZE + BUILTIN_DATA_MAX_SIZE + info_dst_message_length +
info_ts_message_length + statistics_message_length);
}

Locator_t& RTPSParticipantImpl::applyLocatorAdaptRule(
Locator_t& loc)
{
Expand Down Expand Up @@ -490,17 +509,25 @@ bool RTPSParticipantImpl::setup_transports()
socket_descriptor->netmask_filter = socket_descriptor_netmask_filter;
}

if (!is_max_message_size_big_enough(transportDescriptor->max_message_size()))
{
EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT,
"User transport failed to register. Maximum message size needs to be equal or higher than "
"the PDP package size.");
register_transport = false;
}

transportDescriptor->unlock();

if (transport_registered)
{
has_shm_transport_ |=
(dynamic_cast<SharedMemTransportDescriptor*>(transportDescriptor.get()) != nullptr);
(nullptr != dynamic_cast<SharedMemTransportDescriptor*>(transportDescriptor.get()));
}
else
{
// SHM transport could be disabled
if ((dynamic_cast<SharedMemTransportDescriptor*>(transportDescriptor.get()) != nullptr))
if (nullptr != dynamic_cast<SharedMemTransportDescriptor*>(transportDescriptor.get()))
{
EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT,
"Unable to Register SHM Transport. SHM Transport is not supported in"
Expand Down
Loading