From 77d3c27c468d69e2bda0195b2a64d68a921bf783 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 26 May 2019 00:19:26 -0700 Subject: [PATCH] Remove scheduling mode --- .../Kestrel/samples/Http2SampleApp/Program.cs | 3 -- .../Kestrel/samples/PlaintextApp/Startup.cs | 44 +------------------ .../Kestrel/samples/SampleApp/Startup.cs | 3 -- .../Kestrel/samples/SystemdTestApp/Startup.cs | 5 +-- 4 files changed, 2 insertions(+), 53 deletions(-) diff --git a/src/Servers/Kestrel/samples/Http2SampleApp/Program.cs b/src/Servers/Kestrel/samples/Http2SampleApp/Program.cs index f1fc2223cfee..04c4cc90ea4a 100644 --- a/src/Servers/Kestrel/samples/Http2SampleApp/Program.cs +++ b/src/Servers/Kestrel/samples/Http2SampleApp/Program.cs @@ -29,9 +29,6 @@ public static void Main(string[] args) { var basePort = context.Configuration.GetValue("BASE_PORT") ?? 5000; - // Run callbacks on the transport thread - options.ApplicationSchedulingMode = SchedulingMode.Inline; - // Http/1.1 endpoint for comparison options.Listen(IPAddress.Any, basePort, listenOptions => { diff --git a/src/Servers/Kestrel/samples/PlaintextApp/Startup.cs b/src/Servers/Kestrel/samples/PlaintextApp/Startup.cs index 25b1f9e4e2db..044e8b5dfed2 100644 --- a/src/Servers/Kestrel/samples/PlaintextApp/Startup.cs +++ b/src/Servers/Kestrel/samples/PlaintextApp/Startup.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets; namespace PlaintextApp { @@ -40,52 +39,11 @@ public static async Task Main(string[] args) { options.Listen(IPAddress.Loopback, 5001); }) - // .UseLibuv() .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup() .Build(); - var hostTask = host.RunAsync(); - var serverTask = ServerAsync(new SocketTransportFactory(), 5002); - - await hostTask;; - } - - private static async Task ServerAsync(IConnectionListenerFactory factory, int port) - { - await using var listener = await factory.BindAsync(new IPEndPoint(IPAddress.Loopback, port)); - - while (true) - { - var connection = await listener.AcceptAsync(); - - // Fire and forget so we can handle more than a single connection at a time - _ = HandleConnectionAsync(connection); - - static async Task HandleConnectionAsync(ConnectionContext connection) - { - await using (connection) - { - while (true) - { - var result = await connection.Transport.Input.ReadAsync(); - var buffer = result.Buffer; - - foreach (var segment in buffer) - { - await connection.Transport.Output.WriteAsync(segment); - } - - if (result.IsCompleted) - { - break; - } - - connection.Transport.Input.AdvanceTo(buffer.End); - } - } - } - } + await host.RunAsync(); } } diff --git a/src/Servers/Kestrel/samples/SampleApp/Startup.cs b/src/Servers/Kestrel/samples/SampleApp/Startup.cs index 71f218d81603..d279a82034db 100644 --- a/src/Servers/Kestrel/samples/SampleApp/Startup.cs +++ b/src/Servers/Kestrel/samples/SampleApp/Startup.cs @@ -95,9 +95,6 @@ public static Task Main(string[] args) httpsOptions.SslProtocols = SslProtocols.Tls12; }); - // Run callbacks on the transport thread - options.ApplicationSchedulingMode = SchedulingMode.Inline; - options.Listen(IPAddress.Loopback, basePort, listenOptions => { // Uncomment the following to enable Nagle's algorithm for this endpoint. diff --git a/src/Servers/Kestrel/samples/SystemdTestApp/Startup.cs b/src/Servers/Kestrel/samples/SystemdTestApp/Startup.cs index e91322a82795..8888fd143413 100644 --- a/src/Servers/Kestrel/samples/SystemdTestApp/Startup.cs +++ b/src/Servers/Kestrel/samples/SystemdTestApp/Startup.cs @@ -51,9 +51,6 @@ public static Task Main(string[] args) { var basePort = context.Configuration.GetValue("BASE_PORT") ?? 5000; - // Run callbacks on the transport thread - options.ApplicationSchedulingMode = SchedulingMode.Inline; - options.Listen(IPAddress.Loopback, basePort, listenOptions => { // Uncomment the following to enable Nagle's algorithm for this endpoint. @@ -89,4 +86,4 @@ public static Task Main(string[] args) return hostBuilder.Build().RunAsync(); } } -} \ No newline at end of file +}