Merge branch 'release/2.2'

This commit is contained in:
John Luo 2018-08-21 18:42:23 -07:00
commit c9a1a42410
3 changed files with 21 additions and 1 deletions

View File

@ -50,6 +50,6 @@
<XunitPackageVersion>2.3.1</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.4.0</XunitRunnerVisualStudioPackageVersion>
</PropertyGroup>
<PropertyGroup Label="Package Versions: Pinned" />
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
<PropertyGroup Label="Package Versions: Pinned" />
</Project>

View File

@ -21,6 +21,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
{
private static readonly int MinAllocBufferSize = KestrelMemoryPool.MinimumSegmentSize / 2;
private static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
private static readonly bool IsMacOS = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
private readonly Socket _socket;
private readonly PipeScheduler _scheduler;
@ -164,6 +165,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
{
while (true)
{
// MacOS blocked on https://github.com/dotnet/corefx/issues/31766
if (!IsMacOS)
{
// Wait for data before allocating a buffer.
await _receiver.WaitForDataAsync();
}
// Ensure we have some reasonable amount of buffer space
var buffer = Input.GetMemory(MinAllocBufferSize);

View File

@ -13,6 +13,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
{
}
public SocketAwaitableEventArgs WaitForDataAsync()
{
_awaitableEventArgs.SetBuffer(Array.Empty<byte>(), 0, 0);
if (!_socket.ReceiveAsync(_awaitableEventArgs))
{
_awaitableEventArgs.Complete();
}
return _awaitableEventArgs;
}
public SocketAwaitableEventArgs ReceiveAsync(Memory<byte> buffer)
{
#if NETCOREAPP2_1