Skip to content

Commit 9a3ce92

Browse files
Fix reach of maximum buffers in asio::send_to (#5472)
* 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]>
1 parent 5aacaa0 commit 9a3ce92

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/cpp/rtps/messages/RTPSMessageGroup.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434

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

37+
#ifdef FASTDDS_STATISTICS
38+
const size_t max_boost_buffers = 61; // ... + SubMsg header + SubMsg body + Statistics message
39+
#else
40+
const size_t max_boost_buffers = 62; // ... + SubMsg header + SubMsg body
41+
#endif // ifdef FASTDDS_STATISTICS
42+
3743
namespace eprosima {
3844
namespace fastdds {
3945
namespace rtps {
@@ -454,8 +460,8 @@ bool RTPSMessageGroup::insert_submessage(
454460
return false;
455461
}
456462

457-
// Messages with a submessage bigger than 64KB cannot have more submessages and should be flushed
458-
if (is_big_submessage)
463+
// Flush when the submessage is bigger than 64KB OR if the number of buffers to send is 64 (boost limit)
464+
if (is_big_submessage || max_boost_buffers < buffers_to_send_->size())
459465
{
460466
flush();
461467
}

src/cpp/rtps/transport/UDPTransportInterface.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ bool UDPTransportInterface::send(
592592
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, ec.message());
593593
return false;
594594
}
595+
596+
if (bytesSent != total_bytes)
597+
{
598+
EPROSIMA_LOG_WARNING(TRANSPORT_UDP, "Boost send_to wasn't able to send all bytes");
599+
}
595600
}
596601
catch (const std::exception& error)
597602
{

0 commit comments

Comments
 (0)