Skip to content

Commit

Permalink
simplify and remove magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
technobly committed Jul 30, 2018
1 parent 72a80b8 commit 0adac2c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions communication/src/chunked_transfer.cpp
Expand Up @@ -279,8 +279,8 @@ ProtocolError ChunkedTransfer::handle_update_done(token_t token, Message& messag
{
updating = 2; // flag that we are sending missing chunks.
DEBUG("update done - missing chunks starting at %d", index);
chunk_index_t increase = std::max(chunk_index_t(chunk_count*0.2),chunk_index_t(2u)); // ensure always some growth
chunk_index_t resend_chunk_count = std::min(std::max(2u,unsigned(chunk_count+increase)), MISSED_CHUNKS_TO_SEND);
chunk_index_t increase = std::max(unsigned(chunk_count*0.2), MINIMUM_CHUNK_INCREASE); // ensure always some growth
chunk_index_t resend_chunk_count = std::min(unsigned(chunk_count+increase), MISSED_CHUNKS_TO_SEND);
chunk_count = 0;

error = send_missing_chunks(channel, resend_chunk_count);
Expand Down
1 change: 1 addition & 0 deletions communication/src/protocol_defs.h
Expand Up @@ -62,6 +62,7 @@ typedef uint16_t chunk_index_t;
const chunk_index_t NO_CHUNKS_MISSING = 65535;
const chunk_index_t MAX_CHUNKS = 65535;
const size_t MISSED_CHUNKS_TO_SEND = 40u;
const size_t MINIMUM_CHUNK_INCREASE = 2u;
const size_t MAX_EVENT_TTL_SECONDS = 16777215;
const size_t MAX_OPTION_DELTA_LENGTH = 12;
#if PLATFORM_ID<2
Expand Down

0 comments on commit 0adac2c

Please sign in to comment.