Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove connection adapters and move things to middleware #11412

Merged
merged 3 commits into from Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -143,7 +143,6 @@ public partial class ListenOptions : Microsoft.AspNetCore.Connections.IConnectio
{
internal ListenOptions() { }
public System.IServiceProvider ApplicationServices { get { throw null; } }
public System.Collections.Generic.List<Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.IConnectionAdapter> ConnectionAdapters { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public ulong FileHandle { get { throw null; } }
public System.Net.IPEndPoint IPEndPoint { get { throw null; } }
public Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions KestrelServerOptions { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
Expand All @@ -160,24 +159,6 @@ public partial class MinDataRate
public System.TimeSpan GracePeriod { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
}
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastienros This will break the benchmarks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
public partial class ConnectionAdapterContext
{
internal ConnectionAdapterContext() { }
public System.IO.Stream ConnectionStream { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Http.Features.IFeatureCollection Features { get { throw null; } }
}
public partial interface IAdaptedConnection : System.IDisposable
{
System.IO.Stream ConnectionStream { get; }
}
public partial interface IConnectionAdapter
{
bool IsHttps { get; }
System.Threading.Tasks.Task<Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.IAdaptedConnection> OnConnectionAsync(Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.ConnectionAdapterContext context);
}
}
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Features
{
public partial interface IConnectionTimeoutFeature
Expand Down
173 changes: 0 additions & 173 deletions src/Servers/Kestrel/Core/src/Adapter/Internal/AdaptedPipeline.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions src/Servers/Kestrel/Core/src/HttpsConnectionAdapterOptions.cs
Expand Up @@ -2,7 +2,6 @@
// 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.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
Expand Down Expand Up @@ -97,11 +96,5 @@ public TimeSpan HandshakeTimeout
_handshakeTimeout = value != Timeout.InfiniteTimeSpan ? value : TimeSpan.MaxValue;
}
}

internal PipeScheduler Scheduler { get; set; } = PipeScheduler.ThreadPool;

internal long? MaxInputBufferSize { get; set; }

internal long? MaxOutputBufferSize { get; set; }
}
}
5 changes: 2 additions & 3 deletions src/Servers/Kestrel/Core/src/Internal/AddressBinder.cs
Expand Up @@ -171,8 +171,7 @@ public async Task BindAsync(AddressBindContext context)
var httpsDefault = ParseAddress(Constants.DefaultServerHttpsAddress, out https);
context.ServerOptions.ApplyEndpointDefaults(httpsDefault);

if (httpsDefault.ConnectionAdapters.Any(f => f.IsHttps)
|| httpsDefault.TryUseHttps())
if (httpsDefault.IsTls || httpsDefault.TryUseHttps())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this necessary in our last PR? Do we not have anything testing this address strategy?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this change, ParseAddress would never return a ListenOptions object with a ConnectionAdapter pre-attached anyway. It looks like httpsDefault.ConnectionAdapters.Any(f => f.IsHttps) was never tru before and httpsDefault.IsTls is never true now.

More evidence of this is that the https out var is completely ignored.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind. I now see the ApplyEndpointDefaults line. My bad.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was calling UseHttps in the ConfigureEndpointDefaults callback broken before this change?

{
await httpsDefault.BindAsync(context).ConfigureAwait(false);
context.Logger.LogDebug(CoreStrings.BindingToDefaultAddresses,
Expand Down Expand Up @@ -255,7 +254,7 @@ public virtual async Task BindAsync(AddressBindContext context)
var options = ParseAddress(address, out var https);
context.ServerOptions.ApplyEndpointDefaults(options);

if (https && !options.ConnectionAdapters.Any(f => f.IsHttps))
if (https && !options.IsTls)
{
options.UseHttps();
}
Expand Down
Expand Up @@ -86,7 +86,7 @@ internal async Task Execute(KestrelConnection connection)
}
catch (Exception ex)
{
Log.LogCritical(0, ex, $"{nameof(ConnectionDispatcher)}.{nameof(Execute)}() {connectionContext.ConnectionId}");
Log.LogError(0, ex, "Unhandled exception while processing {ConnectionId}.", connectionContext.ConnectionId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this?

Copy link
Member Author

@davidfowl davidfowl Jun 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a critical exception if middleware throws, it's just an error now. Any user code can cause this to happen.

}
}
}
Expand Down