Skip to content

Commit

Permalink
Added explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Aug 12, 2023
1 parent 3bf7bbf commit eb802ea
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ internal async ValueTask WriteAppendEntriesRequestAsync<TEntry, TList>(ClusterMe
{
var entry = entries[i];

if (this.buffer.Length - bufferEnd < LogEntryMetadata.Size + FrameHeadersSize + 1)
// remaining buffer should have free space enough for placing a frame with
// log entry metadata and at least 1 byte for the payload
const int minimumBufferSizeForLogEntry = LogEntryMetadata.Size + FrameHeadersSize + 1;
if (this.buffer.Length - bufferEnd < minimumBufferSizeForLogEntry)
await FlushCoreAsync(token).ConfigureAwait(false);

PrepareForWrite(bufferEnd + WriteLogEntryMetadata(this.buffer.Span.Slice(bufferEnd), entry));
Expand Down

0 comments on commit eb802ea

Please sign in to comment.