Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Fix SslStream.WriteAsync with 0-byte write (#13384)
Browse files Browse the repository at this point in the history
A previous fix added an early exit when 0-byte writes aren't supported by the underlying SSL implementation.  But in doing so, WriteAsync(..., 0) ends up returning a Task that never completes.
  • Loading branch information
stephentoub authored and Petermarcu committed Nov 5, 2016
1 parent 11a75e6 commit 4d1af96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private void StartWriting(byte[] buffer, int offset, int count, AsyncProtocolReq
{
// If it's an empty message and the PAL doesn't support that,
// we're done.
return;
break;
}

// Request a write IO slot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void SslStream_StreamToStream_Successive_ClientWrite_Sync_Success()

[OuterLoop] // TODO: Issue #11345
[Fact]
public void SslStream_StreamToStream_Successive_ClientWrite_Sync_WithZeroBytes_Success()
public void SslStream_StreamToStream_Successive_ClientWrite_WithZeroBytes_Success()
{
byte[] recvBuf = new byte[_sampleMsg.Length];
VirtualNetwork network = new VirtualNetwork();
Expand All @@ -110,13 +110,15 @@ public void SslStream_StreamToStream_Successive_ClientWrite_Sync_WithZeroBytes_S
Assert.True(result, "Handshake completed.");

clientSslStream.Write(Array.Empty<byte>());
clientSslStream.WriteAsync(Array.Empty<byte>(), 0, 0).Wait();
clientSslStream.Write(_sampleMsg);

serverSslStream.Read(recvBuf, 0, _sampleMsg.Length);

Assert.True(VerifyOutput(recvBuf, _sampleMsg), "verify first read data is as expected.");

clientSslStream.Write(_sampleMsg);
clientSslStream.WriteAsync(Array.Empty<byte>(), 0, 0).Wait();
clientSslStream.Write(Array.Empty<byte>());

serverSslStream.Read(recvBuf, 0, _sampleMsg.Length);
Expand Down

0 comments on commit 4d1af96

Please sign in to comment.