Skip to content

Conversation

@davidfowl
Copy link
Member

@davidfowl davidfowl commented May 17, 2019

This is a massive set of changes to Kestrel to remove the existing pubternal transport layer and implement a public facing API for listeners and clients, see the details here #10308.

This change only has the server side pieces of the story as I don't want to add the client APIs without having ported SignalR to use them. Here are the highlights:

  • Transport.Abstractions is empty (will be removed in a separate PR as it requires removing it from a ton of places)
  • TransportConnection has been moved to Connection.Abstractions (we can decide if we need to consolidate with DefaultConnectionContext in a later PR)
  • Added FileHandleEndPoint which allows binding to a file handle (could be a pipe or tcp handle)
  • ListenOptions has been gutted for most pubternal API and returns various types of binding information . The source of truth is the EndPoint instance.
  • Cleaned up a bunch of libuv tests decoupling them from Kestrel.Core

Breaking Changes

  • Removing pubternal API is itself a breaking change but one that we already planned to do.
  • We've removed the ability to set the scheduling mode on Kestrel, this will be a transport knob instead (77d3c27) cc @sebastienros (I know our benchmarks support this)
  • DisposeAsync was added to ConnectionContext (it will implement IAsyncDisposable in a later change, it supports netstandard 2.0 so that requires a bit more work) cc @anurse @BrennanConroy as this affects SignalR (4977f1b)
  • NoDelay is a noop, on ListenOptions, we should consider deprecating it. This has been moved to each of the transports. One major difference though is that it's no longer localized per endpoint but is global. We'd need a derived EndPoint type (or maybe extend IPEndPoint) to store both the socket options and the binding information.

@halter73 this is ready for review now.

Fixes #10308
Fixes #4752

@davidfowl davidfowl requested a review from halter73 May 17, 2019 07:12
{
ValueTask<ConnectionContext> AcceptAsync();

ValueTask DisposeAsync();
Copy link
Member

Choose a reason for hiding this comment

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

Should the interface be bassed on IAsyncDisposable?
Same above in ConnectionContext.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I just hacked it because this is ns2.0.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh...thx.

/// a new instance should be created using the same options.
/// </remarks>
public async Task DisposeAsync()
public override async ValueTask DisposeAsync()
Copy link
Member Author

Choose a reason for hiding this comment

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

@davidfowl
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

@davidfowl
Copy link
Member Author

AHHHHH

EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Protocols.Json", "common\Protocols.Json\src\Microsoft.AspNetCore.SignalR.Protocols.Json.csproj", "{BB52C0FB-19FD-485A-9EBD-3FC173ECAEA0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Metadata", "..\Http\Metadata\src\Microsoft.AspNetCore.Metadata.csproj", "{2E107FBB-2387-4A9F-A2CA-EFDF2E4DD64D}"
Copy link
Member

Choose a reason for hiding this comment

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

You're adding IAllowAnonymous and IAuthorizeData to the SignalR solution in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

I needed it to compile, so pretend its ok. We added a new package but didn't add it to all the places. I had to make sure SignalR was working so I included this in the PR

@davidfowl
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@halter73 halter73 left a comment

Choose a reason for hiding this comment

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

Approved pending finding and fixing the root cause of the UvLoopHandle finalized. It would also be nice if you wrote "Primary"/"Secondary" to the accepted pipes in ListenerPrimaryTests and verified the response.

davidfowl added 2 commits May 29, 2019 23:25
- Added ConfigureAwait(false) to DisposeAsync path
- Added await using in tests to make sure threads are disposed
- Remove more dead code
@davidfowl
Copy link
Member Author

Approved pending finding and fixing the root cause of the UvLoopHandle finalized.

OK I spent a few hours on this and I'm still stumped and haven't been able to write a test to cause the condition to happen. I make a few tweaks to use await using in a couple of places just to make sure we're calling dispose in the right spots.

What if we just add a log here so that we can know if this is a resource leak or a bad unit test?

- Add a method to quickly run through each of the queued aborting all connections instead of using the IAsyncEnumerator.
@davidfowl
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@halter73
Copy link
Member

halter73 commented May 30, 2019

What if we just add a log here so that we can know if this is a resource leak or a bad unit test?

Seems reasonable. We should probably log something anytime OnStopRude() let alone OnStopImmediate() is called. Maybe we could make those logs fail tests like the ungraceful shutdown log does.

/// </remarks>
public bool NoDelay { get; set; } = true;

public long? MaxReadBufferSize { get; set; } = PipeOptions.Default.PauseWriterThreshold;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: doc comments?

@davidfowl davidfowl merged commit 04bf1bf into master May 31, 2019
@ghost ghost deleted the davidfowl/transport-refactor branch May 31, 2019 03:34
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions breaking-change This issue / pr will introduce a breaking change, when resolved / merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client/server networking abstractions Consider letting the transport own the creation of IDuplexPipe