Skip to content

Commit

Permalink
Fix reach of maximum buffers in asio::send_to (#5466) (#5471)
Browse files Browse the repository at this point in the history
* Refs #22439. Fix

Signed-off-by: Ricardo González Moreno <[email protected]>

* Apply suggestions from code review

Co-authored-by: Carlos Ferreira González <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
Co-authored-by: Carlos Ferreira González <[email protected]>
(cherry picked from commit 885878d)

Co-authored-by: Ricardo González <[email protected]>
  • Loading branch information
mergify[bot] and richiware authored Dec 11, 2024
1 parent ffca0ce commit 08eb543
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cpp/rtps/messages/RTPSMessageGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

#include <statistics/rtps/messages/RTPSStatisticsMessages.hpp>

#ifdef FASTDDS_STATISTICS
const size_t max_boost_buffers = 61; // ... + SubMsg header + SubMsg body + Statistics message
#else
const size_t max_boost_buffers = 62; // ... + SubMsg header + SubMsg body
#endif // ifdef FASTDDS_STATISTICS

namespace eprosima {
namespace fastdds {
namespace rtps {
Expand Down Expand Up @@ -454,8 +460,8 @@ bool RTPSMessageGroup::insert_submessage(
return false;
}

// Messages with a submessage bigger than 64KB cannot have more submessages and should be flushed
if (is_big_submessage)
// Flush when the submessage is bigger than 64KB OR if the number of buffers to send is 64 (boost limit)
if (is_big_submessage || max_boost_buffers < buffers_to_send_->size())
{
flush();
}
Expand Down
5 changes: 5 additions & 0 deletions src/cpp/rtps/transport/UDPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ bool UDPTransportInterface::send(
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, ec.message());
return false;
}

if (bytesSent != total_bytes)
{
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "Boost send_to wasn't able to send all bytes");
}
}
catch (const std::exception& error)
{
Expand Down

0 comments on commit 08eb543

Please sign in to comment.