Skip to content

Commit

Permalink
Write the last part of the packet synchronously on Mono.
Browse files Browse the repository at this point in the history
If we use WriteAsync and don't await it, then subsequent WriteAsync may be called before the first continuation returns. If both calls share the same buffer and they overlap, we will overwrite the data in the buffer and cause junk to arrive at receiver.
  • Loading branch information
KirillOsenkov committed Jan 17, 2021
1 parent b7dde7d commit 6eb445d
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -771,7 +771,7 @@ public void SendData(INodePacket packet)
#if FEATURE_APM
_serverToClientStream.BeginWrite(writeStreamBuffer, i, lengthToWrite, PacketWriteComplete, null);
#else
_serverToClientStream.WriteAsync(writeStreamBuffer, i, lengthToWrite);
_serverToClientStream.Write(writeStreamBuffer, i, lengthToWrite);
#endif
return;
}
Expand Down

0 comments on commit 6eb445d

Please sign in to comment.