Skip to content

Commit

Permalink
Fixed error sending more than 256 fragments (#973)
Browse files Browse the repository at this point in the history
* Refs #7399. Applying coding style.

* Refs #7399. Fixed error sending fragments.

Fixed async thread is not awaken when sending more than 256 fragments.

* Refs #7399. Change approach of fix.

* Refs #7399. Fix for synchronous StatelessWriter.

* Refs #7399. Added blackbox tests.

* Refs #7399. Fix for synchronous StatefulWriter.

* Refs #7399. Distinguish reserved_size and max_size on CDRMessage_t

* Refs #7399. Fixing style and warnings.

* Refs #7399. Improve best-effort tests.

Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
richiware and MiguelCompany committed Jan 24, 2020
1 parent c7dd692 commit 136e594
Show file tree
Hide file tree
Showing 5 changed files with 277 additions and 207 deletions.
16 changes: 14 additions & 2 deletions include/fastrtps/rtps/common/CDRMessage_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct RTPS_DllAPI CDRMessage_t{
length = 0;
buffer = (octet*) malloc(RTPSMESSAGE_DEFAULT_SIZE);
max_size = RTPSMESSAGE_DEFAULT_SIZE;
reserved_size = RTPSMESSAGE_DEFAULT_SIZE;

#if __BIG_ENDIAN__
msg_endian = BIGEND;
Expand Down Expand Up @@ -84,6 +85,7 @@ struct RTPS_DllAPI CDRMessage_t{
buffer = nullptr;

max_size = size;
reserved_size = size;

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

CDRMessage_t(const CDRMessage_t& message)
Expand All @@ -113,6 +116,7 @@ struct RTPS_DllAPI CDRMessage_t{
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 @@ -132,6 +136,8 @@ struct RTPS_DllAPI CDRMessage_t{
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 @@ -152,6 +158,8 @@ struct RTPS_DllAPI CDRMessage_t{
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 @@ -168,7 +176,7 @@ struct RTPS_DllAPI CDRMessage_t{
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 @@ -178,9 +186,11 @@ struct RTPS_DllAPI CDRMessage_t{
else
{
buffer = new_buffer;
max_size = size;
reserved_size = size;
}
}

max_size = size;
}

//!Pointer to the buffer where the data is stored.
Expand All @@ -189,6 +199,8 @@ struct RTPS_DllAPI CDRMessage_t{
uint32_t pos;
//!Max size of the message.
uint32_t max_size;
//!Max size of the message.
uint32_t reserved_size;
//!Current length of the message.
uint32_t length;
//!Endianness of the message.
Expand Down
Loading

0 comments on commit 136e594

Please sign in to comment.