Add Backlog to SocketTransportOptions and LibuvTransportOptions (#15111)

This commit is contained in:
Kahbazi 2019-10-21 19:18:51 +03:30 committed by Chris Ross
parent 8255e3ef26
commit c1cc168441
8 changed files with 22 additions and 6 deletions

View File

@ -14,6 +14,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv
public partial class LibuvTransportOptions public partial class LibuvTransportOptions
{ {
public LibuvTransportOptions() { } public LibuvTransportOptions() { }
public int Backlog { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public long? MaxReadBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } public long? MaxReadBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public long? MaxWriteBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } public long? MaxWriteBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public bool NoDelay { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } public bool NoDelay { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -8,8 +8,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{ {
internal static class LibuvConstants internal static class LibuvConstants
{ {
public const int ListenBacklog = 128;
public const int EOF = -4095; public const int EOF = -4095;
public static readonly int? ECONNRESET = GetECONNRESET(); public static readonly int? ECONNRESET = GetECONNRESET();
public static readonly int? EADDRINUSE = GetEADDRINUSE(); public static readonly int? EADDRINUSE = GetEADDRINUSE();

View File

@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
return Thread.PostAsync(listener => return Thread.PostAsync(listener =>
{ {
listener.ListenSocket = listener.CreateListenSocket(); listener.ListenSocket = listener.CreateListenSocket();
listener.ListenSocket.Listen(LibuvConstants.ListenBacklog, ConnectionCallback, listener); listener.ListenSocket.Listen(TransportContext.Options.Backlog, ConnectionCallback, listener);
}, this); }, this);
} }

View File

@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
ListenPipe = new UvPipeHandle(Log); ListenPipe = new UvPipeHandle(Log);
ListenPipe.Init(Thread.Loop, Thread.QueueCloseHandle, false); ListenPipe.Init(Thread.Loop, Thread.QueueCloseHandle, false);
ListenPipe.Bind(_pipeName); ListenPipe.Bind(_pipeName);
ListenPipe.Listen(LibuvConstants.ListenBacklog, ListenPipe.Listen(TransportContext.Options.Backlog,
(pipe, status, error, state) => ((ListenerPrimary)state).OnListenPipe(pipe, status, error), this); (pipe, status, error, state) => ((ListenerPrimary)state).OnListenPipe(pipe, status, error), this);
} }

View File

@ -27,6 +27,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv
/// </remarks> /// </remarks>
public bool NoDelay { get; set; } = true; public bool NoDelay { get; set; } = true;
/// <summary>
/// The maximum length of the pending connection queue.
/// </summary>
/// <remarks>
/// Defaults to 128.
/// </remarks>
public int Backlog { get; set; } = 128;
public long? MaxReadBufferSize { get; set; } = 1024 * 1024; public long? MaxReadBufferSize { get; set; } = 1024 * 1024;
public long? MaxWriteBufferSize { get; set; } = 64 * 1024; public long? MaxWriteBufferSize { get; set; } = 64 * 1024;

View File

@ -19,6 +19,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
public partial class SocketTransportOptions public partial class SocketTransportOptions
{ {
public SocketTransportOptions() { } public SocketTransportOptions() { }
public int Backlog { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public int IOQueueCount { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } public int IOQueueCount { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public long? MaxReadBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } public long? MaxReadBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public long? MaxWriteBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } public long? MaxWriteBufferSize { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }

View File

@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
EndPoint = listenSocket.LocalEndPoint; EndPoint = listenSocket.LocalEndPoint;
listenSocket.Listen(512); listenSocket.Listen(_options.Backlog);
_listenSocket = listenSocket; _listenSocket = listenSocket;
} }

View File

@ -24,6 +24,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
/// </remarks> /// </remarks>
public bool NoDelay { get; set; } = true; public bool NoDelay { get; set; } = true;
/// <summary>
/// The maximum length of the pending connection queue.
/// </summary>
/// <remarks>
/// Defaults to 512.
/// </remarks>
public int Backlog { get; set; } = 512;
public long? MaxReadBufferSize { get; set; } = 1024 * 1024; public long? MaxReadBufferSize { get; set; } = 1024 * 1024;
public long? MaxWriteBufferSize { get; set; } = 64 * 1024; public long? MaxWriteBufferSize { get; set; } = 64 * 1024;