Skip to content

Commit

Permalink
Tweak BufferPtrSendOperation to address argument confusion (#38868)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Jul 7, 2020
1 parent 806aee0 commit c5e6221
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ public BufferPtrSendOperation(SocketAsyncContext context) : base(context) { }
protected override bool DoTryComplete(SocketAsyncContext context)
{
int bufferIndex = 0;
return SocketPal.TryCompleteSendTo(context._socket, new ReadOnlySpan<byte>(BufferPtr, Offset + Count), null, ref bufferIndex, ref Offset, ref Count, Flags, SocketAddress, SocketAddressLen, ref BytesTransferred, out ErrorCode);
int bufferLength = Offset + Count; // TryCompleteSendTo expects the entire buffer, which it then indexes into with the ref Offset and ref Count arguments
return SocketPal.TryCompleteSendTo(context._socket, new ReadOnlySpan<byte>(BufferPtr, bufferLength), null, ref bufferIndex, ref Offset, ref Count, Flags, SocketAddress, SocketAddressLen, ref BytesTransferred, out ErrorCode);
}
}

Expand Down

0 comments on commit c5e6221

Please sign in to comment.