Skip to content

Commit

Permalink
Refs #20589: Set real non_blocking_send limitation
Browse files Browse the repository at this point in the history
Signed-off-by: Jesus Perez <jesusperez@eprosima.com>
  • Loading branch information
jepemi committed Mar 5, 2024
1 parent 5bf8326 commit 5aa3aca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/cpp/rtps/transport/TCPChannelResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ bool TCPChannelResource::check_socket_send_buffer(


size_t future_queue_size = size_t(bytesInSendQueue) + msg_size;
if (future_queue_size > size_t(parent_->configuration()->sendBufferSize))
// TCP actually allocates twice the size of the buffer requested.
if (future_queue_size > size_t(2 * parent_->configuration()->sendBufferSize))
{
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions test/unittest/transport/TCPv4Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,8 @@ TEST_F(TCPv4Tests, secure_non_blocking_send)
const octet* data = message.data();
size_t size = message.size();

// Send the message with no header
// Send the message with no header. Since TCP actually allocates twice the size of the buffer requested
// and we want to guarantee that the buffer might be full, we send the message more than twice.
for (int i = 0; i < 5; i++)
{
sender_channel_resource->send(nullptr, 0, data, size, ec);
Expand Down Expand Up @@ -2019,7 +2020,8 @@ TEST_F(TCPv4Tests, non_blocking_send)
const octet* data = message.data();
size_t size = message.size();

// Send the message with no header
// Send the message with no header. Since TCP actually allocates twice the size of the buffer requested
// and we want to guarantee that the buffer might be full, we send the message more than twice.
for (int i = 0; i < 5; i++)
{
sender_channel_resource->send(nullptr, 0, data, size, ec);
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/transport/TCPv6Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ TEST_F(TCPv6Tests, non_blocking_send)
const octet* data = message.data();
size_t size = message.size();

// Send the message with no header
// Send the message with no header. Since TCP actually allocates twice the size of the buffer requested
// and we want to guarantee that the buffer might be full, we send the message more than twice.
for (int i = 0; i < 5; i++)
{
sender_channel_resource->send(nullptr, 0, data, size, ec);
Expand Down

0 comments on commit 5aa3aca

Please sign in to comment.