diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerContext.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerContext.cs index e5a7ae80e4..f947a17aaa 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerContext.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http/ListenerContext.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http public PipeOptions LibuvPipeOptions => new PipeOptions { - ReaderScheduler = TaskRunScheduler.Default, + ReaderScheduler = ServiceContext.ThreadPool, WriterScheduler = Thread, MaximumSizeHigh = ServiceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0, MaximumSizeLow = ServiceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0 diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/IThreadPool.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/IThreadPool.cs index af5b6df175..48db68ff10 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/IThreadPool.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/IThreadPool.cs @@ -2,12 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IO.Pipelines; using System.Threading; using System.Threading.Tasks; namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure { - public interface IThreadPool + public interface IThreadPool : IScheduler { void Complete(TaskCompletionSource tcs); void Cancel(TaskCompletionSource tcs); diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/LoggingThreadPool.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/LoggingThreadPool.cs index 1cc2f52491..d0cff5e9ac 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/LoggingThreadPool.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/LoggingThreadPool.cs @@ -112,5 +112,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure } }, tcs); } + + public void Schedule(Action action) + { + Run(action); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/TestHelpers/SynchronousThreadPool.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/TestHelpers/SynchronousThreadPool.cs index 15994044d2..b4d35e6ee5 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/TestHelpers/SynchronousThreadPool.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/TestHelpers/SynchronousThreadPool.cs @@ -34,5 +34,10 @@ namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers { action(state); } + + public void Schedule(Action action) + { + action(); + } } }