From 08eb54332ee92f1bfbc73b22a3eb398833922521 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:22:57 +0100 Subject: [PATCH] Fix reach of maximum buffers in asio::send_to (#5466) (#5471) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #22439. Fix Signed-off-by: Ricardo González Moreno * Apply suggestions from code review Co-authored-by: Carlos Ferreira González --------- Signed-off-by: Ricardo González Moreno Co-authored-by: Carlos Ferreira González (cherry picked from commit 885878ddbdaceff4c112bde2c3aec11e0d30ca13) Co-authored-by: Ricardo González --- src/cpp/rtps/messages/RTPSMessageGroup.cpp | 10 ++++++++-- src/cpp/rtps/transport/UDPTransportInterface.cpp | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cpp/rtps/messages/RTPSMessageGroup.cpp b/src/cpp/rtps/messages/RTPSMessageGroup.cpp index e3752a8fda2..8df52318643 100644 --- a/src/cpp/rtps/messages/RTPSMessageGroup.cpp +++ b/src/cpp/rtps/messages/RTPSMessageGroup.cpp @@ -34,6 +34,12 @@ #include +#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 { @@ -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(); } diff --git a/src/cpp/rtps/transport/UDPTransportInterface.cpp b/src/cpp/rtps/transport/UDPTransportInterface.cpp index 95105eeb855..cd9b11e48d4 100644 --- a/src/cpp/rtps/transport/UDPTransportInterface.cpp +++ b/src/cpp/rtps/transport/UDPTransportInterface.cpp @@ -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) {