Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogs9 authored and Your Name committed Nov 16, 2020
1 parent dd4a6e4 commit c0fc2d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/c/core/session/stream/output_reliable_stream.c
Expand Up @@ -85,17 +85,18 @@ bool uxr_prepare_reliable_buffer_to_write(uxrOutputReliableStream* stream, size_
/* Check if the message fit in a fragmented message */
else
{
size_t remaining_blocks = uxr_seq_num_sub(stream->last_acknown, seq_num) % stream->base.history;

/* Check if the current buffer free space is too small */
if(buffer_size + (size_t)SUBHEADER_SIZE >= buffer_capacity)
{
seq_num = uxr_seq_num_add(seq_num, 1);
buffer = uxr_get_reliable_buffer(&stream->base, seq_num);
buffer_size = uxr_get_reliable_buffer_size(&stream->base, seq_num);
remaining_blocks = (0 < remaining_blocks) ? remaining_blocks - 1 : 0;
}

size_t used_blocks = uxr_seq_num_sub(seq_num, stream->last_acknown);
used_blocks = (used_blocks == 0) ? 0 : used_blocks - 1;
size_t remaining_blocks = stream->base.history - used_blocks;

uint16_t available_block_size = (uint16_t)(buffer_capacity - (uint16_t)(stream->offset + SUBHEADER_SIZE));
uint16_t first_fragment_size = (uint16_t)(buffer_capacity - (uint16_t)(buffer_size + SUBHEADER_SIZE));
uint16_t remaining_size = (uint16_t)(length - first_fragment_size);
Expand Down

0 comments on commit c0fc2d6

Please sign in to comment.