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

Fixed error sending more than 256 fragments <master> [7404] #974

Merged
merged 10 commits into from
Feb 28, 2020
15 changes: 13 additions & 2 deletions include/fastdds/rtps/common/CDRMessage_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct RTPS_DllAPI CDRMessage_t final
}

max_size = size;
reserved_size = size;

#if __BIG_ENDIAN__
msg_endian = BIGEND;
Expand All @@ -105,6 +106,7 @@ struct RTPS_DllAPI CDRMessage_t final
length = payload.length;
buffer = payload.data;
max_size = payload.max_size;
reserved_size = payload.max_size;
}

CDRMessage_t(
Expand All @@ -116,6 +118,7 @@ struct RTPS_DllAPI CDRMessage_t final
max_size = message.max_size;
msg_endian = message.msg_endian;

reserved_size = max_size;
if (max_size != 0)
{
buffer = (octet*)malloc(max_size);
Expand All @@ -138,6 +141,8 @@ struct RTPS_DllAPI CDRMessage_t final
message.length = 0;
max_size = message.max_size;
message.max_size = 0;
reserved_size = message.reserved_size;
message.reserved_size = 0;
msg_endian = message.msg_endian;
#if __BIG_ENDIAN__
message.msg_endian = BIGEND;
Expand All @@ -159,6 +164,8 @@ struct RTPS_DllAPI CDRMessage_t final
message.length = 0;
max_size = message.max_size;
message.max_size = 0;
reserved_size = message.reserved_size;
message.reserved_size = 0;
msg_endian = message.msg_endian;
#if __BIG_ENDIAN__
message.msg_endian = BIGEND;
Expand All @@ -175,7 +182,7 @@ struct RTPS_DllAPI CDRMessage_t final
uint32_t size)
{
assert(wraps == false);
if (size > max_size)
if (size > reserved_size)
{
octet* new_buffer = (octet*) realloc(buffer, size);
if (new_buffer == nullptr)
Expand All @@ -185,9 +192,11 @@ struct RTPS_DllAPI CDRMessage_t final
else
{
buffer = new_buffer;
max_size = size;
reserved_size = size;
}
}

max_size = size;
}

//!Pointer to the buffer where the data is stored.
Expand All @@ -196,6 +205,8 @@ struct RTPS_DllAPI CDRMessage_t final
uint32_t pos;
//!Max size of the message.
uint32_t max_size;
//!Size allocated on buffer. May be higher than max_size.
uint32_t reserved_size;
IkerLuengo marked this conversation as resolved.
Show resolved Hide resolved
//!Current length of the message.
uint32_t length;
//!Endianness of the message.
Expand Down