Rename namespaces/directories/classes in Kestrel.Core and Transport.Libuv (#1582).

- Put everything in the libuv transport package under `Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.*` namespaces.
- Move stuff in Transport.Libuv/Internal/Http and Transport.Libuv/Internal/Infrastructure to Transport.Libuv/Internal (keep the Networking directory for the libuv wrappers).
- Add `Libuv` prefix to most libuv internal classes.
- Rename `KestrelEngine` to `LibuvTransport`.
- Rename `SocketOutputConsumer` to `LibuvOutputConsumer`.
- Rename `SocketOutputProducer` to `OutputProducer`.
- Fix namespaces in `Microsoft.AspNetCore.Server.Kestrel.Core.`
This commit is contained in:
Cesar Blum Silveira 2017-04-04 13:45:02 -07:00 committed by GitHub
parent e0de7f1e1e
commit 7ceea5323a
183 changed files with 459 additions and 493 deletions

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.Extensions.Logging;
namespace SampleApp

View File

@ -3,7 +3,7 @@
using System.IO;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter
{
// Even though this only includes the non-adapted ConnectionStream currently, this is a context in case
// we want to add more connection metadata later.

View File

@ -4,7 +4,7 @@
using System.IO;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter
{
public interface IAdaptedConnection
{

View File

@ -3,7 +3,7 @@
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter
{
public interface IConnectionAdapter
{

View File

@ -5,9 +5,9 @@ using System;
using System.IO;
using System.IO.Pipelines;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
{
public class AdaptedPipeline
{

View File

@ -8,7 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
{
internal class LoggingStream : Stream
{

View File

@ -6,9 +6,9 @@ using System.IO;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
{
public class RawStream : Stream
{

View File

@ -6,9 +6,9 @@ using System.IO;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
{
public class StreamSocketOutput : ISocketOutput
{

View File

@ -1,8 +1,8 @@
// 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.
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.AspNetCore.Server.Kestrel.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

View File

@ -5,10 +5,10 @@ using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Adapter.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Adapter
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter
{
public class LoggingConnectionAdapter : IConnectionAdapter
{

View File

@ -3,11 +3,11 @@
using System.IO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Server.Kestrel
namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
public sealed class BadHttpRequestException : IOException
{

View File

@ -3,11 +3,11 @@
using System.IO.Pipelines;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class ConnectionHandler<TContext> : IConnectionHandler
{
@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
// TODO: Untangle this mess
var frame = new Frame<TContext>(_application, frameContext);
var outputProducer = new SocketOutputProducer(outputPipe.Writer, frame, connectionId, _serviceContext.Log);
var outputProducer = new OutputProducer(outputPipe.Writer, frame, connectionId, _serviceContext.Log);
frame.LifetimeControl = new ConnectionLifetimeControl(connectionId, outputPipe.Reader, outputProducer, _serviceContext.Log);
var connection = new FrameConnection(new FrameConnectionContext

View File

@ -6,15 +6,15 @@ using System.Collections.Generic;
using System.IO;
using System.IO.Pipelines;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Adapter.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class FrameConnection : IConnectionContext
{

View File

@ -3,10 +3,10 @@
using System.Collections.Generic;
using System.IO.Pipelines;
using Microsoft.AspNetCore.Server.Kestrel.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class FrameConnectionContext
{
@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
public PipeFactory PipeFactory { get; set; }
public List<IConnectionAdapter> ConnectionAdapters { get; set; }
public Frame Frame { get; set; }
public SocketOutputProducer OutputProducer { get; set; }
public OutputProducer OutputProducer { get; set; }
public IPipe Input { get; set; }
public IPipe Output { get; set; }

View File

@ -5,7 +5,7 @@ using System;
using System.IO.Pipelines;
using System.Text;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public static class ChunkWriter
{

View File

@ -2,16 +2,16 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO.Pipelines;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class ConnectionLifetimeControl
{
public ConnectionLifetimeControl(
string connectionId,
IPipeReader outputPipeReader,
SocketOutputProducer outputProducer,
OutputProducer outputProducer,
IKestrelTrace log)
{
ConnectionId = connectionId;
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
private string ConnectionId { get; }
private IPipeReader OutputReader { get; }
private SocketOutputProducer OutputProducer { get; }
private OutputProducer OutputProducer { get; }
private IKestrelTrace Log { get; }
public void End(ProduceEndType endType)

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
[Flags]
public enum ConnectionOptions

View File

@ -4,10 +4,10 @@
using System;
using System.Text;
using System.Threading;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
/// <summary>
/// Manages the generation of the date header value.

View File

@ -12,7 +12,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class Frame : IFeatureCollection,
IHttpRequestFeature,

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class Frame
{

View File

@ -14,8 +14,8 @@ using System.Text.Encodings.Web.Utf8;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.Logging;
@ -23,7 +23,7 @@ using Microsoft.Extensions.Primitives;
// ReSharper disable AccessToModifiedClosure
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public abstract partial class Frame : IFrameControl, IHttpRequestLineHandler, IHttpHeadersHandler
{

View File

@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class FrameContext
{

View File

@ -8,7 +8,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
class FrameDuplexStream : Stream
{

View File

@ -4,11 +4,11 @@
using System;
using System.Collections.Generic;
using System.IO.Pipelines;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class FrameRequestHeaders

View File

@ -9,7 +9,7 @@ using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public abstract class FrameHeaders : IHeaderDictionary
{

View File

@ -6,11 +6,11 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class Frame<TContext> : Frame
{

View File

@ -5,11 +5,11 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class FrameRequestHeaders : FrameHeaders
{

View File

@ -7,7 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
class FrameRequestStream : Stream
{

View File

@ -9,7 +9,7 @@ using System.Runtime.CompilerServices;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class FrameResponseHeaders : FrameHeaders
{

View File

@ -6,7 +6,7 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
class FrameResponseStream : Stream
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
enum FrameStreamState
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum HttpMethod: byte
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum HttpScheme
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum HttpVersion
{

View File

@ -5,7 +5,7 @@ using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public interface IFrameControl
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public interface IHttpHeadersHandler
{

View File

@ -3,7 +3,7 @@
using System.IO.Pipelines;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public interface IHttpParser
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public interface IHttpRequestLineHandler
{

View File

@ -6,7 +6,7 @@ using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
/// <summary>
/// Operations performed for buffered socket output

View File

@ -5,10 +5,10 @@ using System;
using System.IO.Pipelines;
using System.Numerics;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class KestrelHttpParser : IHttpParser
{

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public abstract class MessageBody
{

View File

@ -5,12 +5,12 @@ using System;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class SocketOutputProducer : ISocketOutput, IDisposable
public class OutputProducer : ISocketOutput, IDisposable
{
private static readonly ArraySegment<byte> _emptyData = new ArraySegment<byte>(new byte[0]);
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
private readonly object _flushLock = new object();
private readonly Action _onFlushCallback;
public SocketOutputProducer(IPipeWriter pipe, Frame frame, string connectionId, IKestrelTrace log)
public OutputProducer(IPipeWriter pipe, Frame frame, string connectionId, IKestrelTrace log)
{
_pipe = pipe;
_frame = frame;

View File

@ -4,7 +4,7 @@
using System;
using System.Diagnostics;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public static class PathNormalizer
{

View File

@ -7,7 +7,7 @@ using System.IO.Pipelines;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public static class PipelineExtensions
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum ProduceEndType
{

View File

@ -6,7 +6,7 @@ using System.Globalization;
using System.Text;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public static class ReasonPhrases
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum RequestProcessingStatus
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum RequestRejectionReason
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
[Flags]
public enum TransferCoding

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
internal class AsciiUtilities
{

View File

@ -4,7 +4,7 @@
using System;
using System.Threading;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
internal static class CancellationTokenExtensions
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
internal static class Constants
{

View File

@ -4,7 +4,7 @@
using System;
using System.Threading;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
internal static class CorrelationIdGenerator
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
/// <summary>
/// Summary description for Disposable

View File

@ -4,7 +4,7 @@
using System;
using System.Threading;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
internal class DisposableAction : IDisposable
{

View File

@ -6,9 +6,9 @@ using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
public static class HttpUtilities
{

View File

@ -4,7 +4,7 @@
using System;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
public interface IKestrelTrace : ILogger
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
/// <summary>
/// Abstracts the system clock to facilitate testing.

View File

@ -6,7 +6,7 @@ using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
public interface IThreadPool : IScheduler
{

View File

@ -6,7 +6,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
public class InlineLoggingThreadPool : IThreadPool
{

View File

@ -3,10 +3,10 @@
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
[EventSource(Name = "Microsoft-AspNetCore-Server-Kestrel")]
public sealed class KestrelEventSource : EventSource

View File

@ -2,10 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
/// <summary>
/// Summary description for KestrelTrace

View File

@ -6,7 +6,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
public class LoggingThreadPool : IThreadPool
{

View File

@ -1,9 +1,9 @@
// 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.
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
class Streams
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
/// <summary>
/// Provides access to the normal system clock.

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{
public class UriUtilities
{

View File

@ -1,7 +1,7 @@
// 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.
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class InternalKestrelServerOptions
{

View File

@ -4,7 +4,7 @@
using System;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class KestrelServerOptionsSetup : IConfigureOptions<KestrelServerOptions>
{

View File

@ -2,10 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class ServiceContext
{

View File

@ -12,14 +12,13 @@ using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Server.Kestrel
namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
public class KestrelServer : IServer
{

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel
namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
public class KestrelServerLimits
{

View File

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic;
using System.Net;
namespace Microsoft.AspNetCore.Server.Kestrel
namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
/// <summary>
/// Provides programmatic configuration of Kestrel-specific features.

View File

@ -4,10 +4,10 @@
using System;
using System.Collections.Generic;
using System.Net;
using Microsoft.AspNetCore.Server.Kestrel.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
namespace Microsoft.AspNetCore.Server.Kestrel
namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
/// <summary>
/// Describes either an <see cref="IPEndPoint"/>, Unix domain socket path, or a file descriptor for an already open

View File

@ -4,9 +4,9 @@
using System;
using System.Diagnostics;
using System.Globalization;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel
namespace Microsoft.AspNetCore.Server.Kestrel.Core
{
public class ServerAddress
{

View File

@ -4,7 +4,7 @@
using System;
using System.Diagnostics;
using System.Globalization;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.AspNetCore.Server.Kestrel.Core;
namespace Microsoft.AspNetCore.Hosting
{

View File

@ -7,7 +7,7 @@ using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter;
using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
using Microsoft.Extensions.Logging;

View File

@ -3,7 +3,7 @@
using System.IO;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Https;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

View File

@ -3,7 +3,7 @@
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
interface IAsyncDisposable
{

View File

@ -4,7 +4,7 @@
using System;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public interface ILibuvTrace : ILogger
{

View File

@ -5,9 +5,9 @@ using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public class LibuvAwaitable<TRequest> : ICriticalNotifyCompletion where TRequest : UvRequest
{

View File

@ -7,15 +7,13 @@ using System.IO;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public class Connection : ConnectionContext, ITimeoutControl
public class LibuvConnection : LibuvConnectionContext, ITimeoutControl
{
private const int MinAllocBufferSize = 2048;
@ -35,7 +33,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
private TimeoutAction _timeoutAction;
private WritableBuffer? _currentWritableBuffer;
public Connection(ListenerContext context, UvStreamHandle socket) : base(context)
public LibuvConnection(ListenerContext context, UvStreamHandle socket) : base(context)
{
_socket = socket;
socket.Connection = this;
@ -52,17 +50,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
}
// For testing
public Connection()
public LibuvConnection()
{
}
public string ConnectionId { get; set; }
public IPipeWriter Input { get; set; }
public SocketOutputConsumer Output { get; set; }
public LibuvOutputConsumer Output { get; set; }
private ILibuvTrace Log => ListenerContext.TransportContext.Log;
private IConnectionHandler ConnectionHandler => ListenerContext.TransportContext.ConnectionHandler;
private KestrelThread Thread => ListenerContext.Thread;
private LibuvThread Thread => ListenerContext.Thread;
public void Start()
{
@ -72,7 +70,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
ConnectionId = _connectionContext.ConnectionId;
Input = _connectionContext.Input;
Output = new SocketOutputConsumer(_connectionContext.Output, Thread, _socket, this, ConnectionId, Log);
Output = new LibuvOutputConsumer(_connectionContext.Output, Thread, _socket, this, ConnectionId, Log);
// Start socket prior to applying the ConnectionAdapter
_socket.ReadStart(_allocCallback, _readCallback, this);
@ -132,7 +130,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
private static LibuvFunctions.uv_buf_t AllocCallback(UvStreamHandle handle, int suggestedSize, object state)
{
return ((Connection)state).OnAlloc(handle, suggestedSize);
return ((LibuvConnection)state).OnAlloc(handle, suggestedSize);
}
private unsafe LibuvFunctions.uv_buf_t OnAlloc(UvStreamHandle handle, int suggestedSize)
@ -151,13 +149,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
private static void ReadCallback(UvStreamHandle handle, int status, object state)
{
((Connection)state).OnRead(handle, status);
((LibuvConnection)state).OnRead(handle, status);
}
private async void OnRead(UvStreamHandle handle, int status)
{
var normalRead = status >= 0;
var normalDone = status == Constants.EOF;
var normalDone = status == LibuvConstants.EOF;
var errorDone = !(normalDone || normalRead);
var readCount = normalRead ? status : 0;
@ -183,7 +181,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
handle.Libuv.Check(status, out uvError);
// Log connection resets at a lower (Debug) level.
if (status == Constants.ECONNRESET)
if (status == LibuvConstants.ECONNRESET)
{
Log.ConnectionReset(ConnectionId);
error = new ConnectionResetException(uvError.Message, uvError);
@ -273,8 +271,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
{
_timeoutAction = timeoutAction;
// Add KestrelThread.HeartbeatMilliseconds extra milliseconds since this can be called right before the next heartbeat.
Interlocked.Exchange(ref _timeoutTimestamp, _lastTimestamp + milliseconds + KestrelThread.HeartbeatMilliseconds);
// Add LibuvThread.HeartbeatMilliseconds extra milliseconds since this can be called right before the next heartbeat.
Interlocked.Exchange(ref _timeoutTimestamp, _lastTimestamp + milliseconds + LibuvThread.HeartbeatMilliseconds);
}
}
}

View File

@ -5,15 +5,15 @@ using System.IO.Pipelines;
using System.Net;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public class ConnectionContext : IConnectionInformation
public class LibuvConnectionContext : IConnectionInformation
{
public ConnectionContext()
public LibuvConnectionContext()
{
}
public ConnectionContext(ListenerContext context)
public LibuvConnectionContext(ListenerContext context)
{
ListenerContext = context;
}

View File

@ -4,15 +4,15 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public class ConnectionManager
public class LibuvConnectionManager
{
private readonly KestrelThread _thread;
private readonly LibuvThread _thread;
public ConnectionManager(KestrelThread thread)
public LibuvConnectionManager(LibuvThread thread)
{
_thread = thread;
}
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
return await WalkConnectionsAsync((connectionManager, tcs) => connectionManager.WalkConnectionsAndAbortCore(tcs), timeout).ConfigureAwait(false);
}
private async Task<bool> WalkConnectionsAsync(Action<ConnectionManager, TaskCompletionSource<object>> action, TimeSpan timeout)
private async Task<bool> WalkConnectionsAsync(Action<LibuvConnectionManager, TaskCompletionSource<object>> action, TimeSpan timeout)
{
var tcs = new TaskCompletionSource<object>();
@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
WalkConnectionsCore(connection => connection.AbortAsync(), tcs);
}
private void WalkConnectionsCore(Func<Connection, Task> action, TaskCompletionSource<object> tcs)
private void WalkConnectionsCore(Func<LibuvConnection, Task> action, TaskCompletionSource<object> tcs)
{
var tasks = new List<Task>();

View File

@ -3,9 +3,9 @@
using System.Runtime.InteropServices;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
internal static class Constants
internal static class LibuvConstants
{
public const int ListenBacklog = 128;

View File

@ -4,28 +4,26 @@
using System;
using System.IO.Pipelines;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public class SocketOutputConsumer
public class LibuvOutputConsumer
{
private readonly KestrelThread _thread;
private readonly LibuvThread _thread;
private readonly UvStreamHandle _socket;
private readonly Connection _connection;
private readonly LibuvConnection _connection;
private readonly string _connectionId;
private readonly ILibuvTrace _log;
private readonly WriteReqPool _writeReqPool;
private readonly IPipeReader _pipe;
public SocketOutputConsumer(
public LibuvOutputConsumer(
IPipeReader pipe,
KestrelThread thread,
LibuvThread thread,
UvStreamHandle socket,
Connection connection,
LibuvConnection connection,
string connectionId,
ILibuvTrace log)
{
@ -104,7 +102,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
else
{
// Log connection resets at a lower (Debug) level.
if (status == Constants.ECONNRESET)
if (status == LibuvConstants.ECONNRESET)
{
_log.ConnectionReset(_connectionId);
}

View File

@ -9,18 +9,12 @@ using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
/// <summary>
/// Summary description for KestrelThread
/// </summary>
public class KestrelThread : IScheduler
public class LibuvThread : IScheduler
{
public const long HeartbeatMilliseconds = 1000;
@ -28,8 +22,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
{
var streamHandle = UvMemory.FromIntPtr<UvHandle>(ptr) as UvStreamHandle;
var thisHandle = GCHandle.FromIntPtr(arg);
var kestrelThread = (KestrelThread)thisHandle.Target;
streamHandle?.Connection?.Tick(kestrelThread.Now);
var libuvThread = (LibuvThread)thisHandle.Target;
streamHandle?.Connection?.Tick(libuvThread.Now);
};
// maximum times the work queues swapped and are processed in a single pass
@ -37,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
// otherwise it needs to wait till the next pass of the libuv loop
private readonly int _maxLoops = 8;
private readonly KestrelEngine _engine;
private readonly LibuvTransport _transport;
private readonly IApplicationLifetime _appLifetime;
private readonly Thread _thread;
private readonly TaskCompletionSource<object> _threadTcs = new TaskCompletionSource<object>();
@ -57,16 +51,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
private readonly TimeSpan _shutdownTimeout;
private IntPtr _thisPtr;
public KestrelThread(KestrelEngine engine)
public LibuvThread(LibuvTransport transport)
{
_engine = engine;
_appLifetime = engine.AppLifetime;
_log = engine.Log;
_shutdownTimeout = engine.TransportOptions.ShutdownTimeout;
_transport = transport;
_appLifetime = transport.AppLifetime;
_log = transport.Log;
_shutdownTimeout = transport.TransportOptions.ShutdownTimeout;
_loop = new UvLoopHandle(_log);
_post = new UvAsyncHandle(_log);
_thread = new Thread(ThreadStart);
_thread.Name = "KestrelThread - libuv";
_thread.Name = nameof(LibuvThread);
_heartbeatTimer = new UvTimerHandle(_log);
#if !DEBUG
// Mark the thread as being as unimportant to keeping the process alive.
@ -77,12 +71,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
QueueCloseAsyncHandle = EnqueueCloseHandle;
PipelineFactory = new PipeFactory();
WriteReqPool = new WriteReqPool(this, _log);
ConnectionManager = new ConnectionManager(this);
ConnectionManager = new LibuvConnectionManager(this);
}
// For testing
public KestrelThread(KestrelEngine engine, int maxLoops)
: this(engine)
public LibuvThread(LibuvTransport transport, int maxLoops)
: this(transport)
{
_maxLoops = maxLoops;
}
@ -91,7 +85,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
public PipeFactory PipelineFactory { get; }
public ConnectionManager ConnectionManager { get; }
public LibuvConnectionManager ConnectionManager { get; }
public WriteReqPool WriteReqPool { get; }
@ -140,7 +134,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
Post(t => t.OnStopImmediate());
if (!await WaitAsync(_threadTcs.Task, stepTimeout).ConfigureAwait(false))
{
_log.LogCritical("KestrelThread.StopAsync failed to terminate libuv thread.");
_log.LogCritical($"{nameof(LibuvThread)}.{nameof(StopAsync)} failed to terminate libuv thread.");
}
}
}
@ -149,7 +143,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
// Until we rework this logic, ODEs are bound to happen sometimes.
if (!await WaitAsync(_threadTcs.Task, stepTimeout).ConfigureAwait(false))
{
_log.LogCritical("KestrelThread.StopAsync failed to terminate libuv thread.");
_log.LogCritical($"{nameof(LibuvThread)}.{nameof(StopAsync)} failed to terminate libuv thread.");
}
}
}
@ -236,7 +230,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
_post.Send();
}
private void Post(Action<KestrelThread> callback)
private void Post(Action<LibuvThread> callback)
{
Post(callback, this);
}
@ -265,7 +259,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
private void Walk(LibuvFunctions.uv_walk_cb callback, IntPtr arg)
{
_engine.Libuv.walk(
_transport.Libuv.walk(
_loop,
callback,
arg
@ -293,7 +287,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
var tcs = (TaskCompletionSource<int>)parameter;
try
{
_loop.Init(_engine.Libuv);
_loop.Init(_transport.Libuv);
_post.Init(_loop, OnPost, EnqueueCloseHandle);
_heartbeatTimer.Init(_loop, EnqueueCloseHandle);
_heartbeatTimer.Start(OnHeartbeat, timeout: HeartbeatMilliseconds, repeat: HeartbeatMilliseconds);
@ -391,7 +385,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
}
catch (Exception e)
{
_log.LogError(0, e, "KestrelThread.DoPostWork");
_log.LogError(0, e, $"{nameof(LibuvThread)}.{nameof(DoPostWork)}");
}
}, work.Completion);
}
@ -408,13 +402,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
}
catch (Exception e)
{
_log.LogError(0, e, "KestrelThread.DoPostWork");
_log.LogError(0, e, $"{nameof(LibuvThread)}.{nameof(DoPostWork)}");
}
}, work.Completion);
}
else
{
_log.LogError(0, ex, "KestrelThread.DoPostWork");
_log.LogError(0, ex, $"{nameof(LibuvThread)}.{nameof(DoPostWork)}");
throw;
}
}
@ -444,7 +438,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
}
catch (Exception ex)
{
_log.LogError(0, ex, "KestrelThread.DoPostCloseHandle");
_log.LogError(0, ex, $"{nameof(LibuvThread)}.{nameof(DoPostCloseHandle)}");
throw;
}
}

View File

@ -4,7 +4,7 @@
using System;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public class LibuvTrace : ILibuvTrace
{

View File

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{

View File

@ -3,14 +3,11 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
/// <summary>
/// Base class for listeners in Kestrel. Listens for incoming connections
@ -29,7 +26,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
public Task StartAsync(
IEndPointInformation endPointInformation,
KestrelThread thread)
LibuvThread thread)
{
EndPointInformation = endPointInformation;
Thread = thread;
@ -43,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
{
var listener = ((Listener) tcs2.Task.AsyncState);
listener.ListenSocket = listener.CreateListenSocket();
ListenSocket.Listen(Constants.ListenBacklog, ConnectionCallback, this);
ListenSocket.Listen(LibuvConstants.ListenBacklog, ConnectionCallback, this);
tcs2.SetResult(0);
}
catch (Exception ex)
@ -148,7 +145,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
protected virtual void DispatchConnection(UvStreamHandle socket)
{
var connection = new Connection(this, socket);
var connection = new LibuvConnection(this, socket);
connection.Start();
}
@ -156,7 +153,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
{
// Ensure the event loop is still running.
// If the event loop isn't running and we try to wait on this Post
// to complete, then KestrelEngine will never be disposed and
// to complete, then LibuvTransport will never be disposed and
// the exception that stopped the event loop will never be surfaced.
if (Thread.FatalError == null && ListenSocket != null)
{

View File

@ -2,11 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
public class ListenerContext
{
@ -19,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
public IEndPointInformation EndPointInformation { get; set; }
public KestrelThread Thread { get; set; }
public LibuvThread Thread { get; set; }
/// <summary>
/// Creates a socket which can be used to accept an incoming connection.

View File

@ -6,13 +6,11 @@ using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
/// <summary>
/// A primary listener waits for incoming connections on a specified socket. Incoming
@ -41,7 +39,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
string pipeName,
byte[] pipeMessage,
IEndPointInformation endPointInformation,
KestrelThread thread)
LibuvThread thread)
{
_pipeName = pipeName;
_pipeMessage = pipeMessage;
@ -64,7 +62,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
ListenPipe = new UvPipeHandle(Log);
ListenPipe.Init(Thread.Loop, Thread.QueueCloseHandle, false);
ListenPipe.Bind(_pipeName);
ListenPipe.Listen(Constants.ListenBacklog,
ListenPipe.Listen(LibuvConstants.ListenBacklog,
(pipe, status, error, state) => ((ListenerPrimary)state).OnListenPipe(pipe, status, error), this);
}

View File

@ -5,14 +5,11 @@ using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Networking;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
{
/// <summary>
/// A secondary listener is delegated requests from a primary listener via a named pipe or
@ -39,7 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
string pipeName,
byte[] pipeMessage,
IEndPointInformation endPointInformation,
KestrelThread thread)
LibuvThread thread)
{
_pipeName = pipeName;
_pipeMessage = pipeMessage;
@ -130,7 +127,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
{
if (status < 0)
{
if (status != Constants.EOF)
if (status != LibuvConstants.EOF)
{
Exception ex;
Thread.Loop.Libuv.Check(status, out ex);
@ -161,7 +158,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
try
{
var connection = new Connection(this, acceptSocket);
var connection = new LibuvConnection(this, acceptSocket);
connection.Start();
}
catch (UvException ex)
@ -184,7 +181,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
{
// Ensure the event loop is still running.
// If the event loop isn't running and we try to wait on this Post
// to complete, then KestrelEngine will never be disposed and
// to complete, then LibuvTransport will never be disposed and
// the exception that stopped the event loop will never be surfaced.
if (Thread.FatalError == null)
{

View File

@ -5,7 +5,7 @@ using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
public class LibuvFunctions
{

View File

@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
public static class PlatformApis
{

View File

@ -4,7 +4,7 @@
using System.Net;
using System.Runtime.InteropServices;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
[StructLayout(LayoutKind.Sequential)]
public struct SockAddr

View File

@ -4,10 +4,8 @@
using System;
using System.Diagnostics;
using System.Threading;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
public class UvAsyncHandle : UvHandle
{

View File

@ -2,11 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
/// <summary>
/// Summary description for UvWriteRequest

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
public class UvException : Exception
{

View File

@ -4,10 +4,8 @@
using System;
using System.Diagnostics;
using System.Threading;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
public abstract class UvHandle : UvMemory
{

View File

@ -3,10 +3,8 @@
using System;
using System.Threading;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Networking
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking
{
public class UvLoopHandle : UvMemory
{

Some files were not shown because too many files have changed in this diff Show More