Skip to content

Better handle HttpConnectionContext state transitions #8225

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

Merged
merged 8 commits into from
Mar 14, 2019

Conversation

halter73
Copy link
Member

@halter73 halter73 commented Mar 6, 2019

Possible alternative to #8114

// Capture the connection state
status = connection.Status;

lastSeenUtc = connection.LastSeenUtc;
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes a potential race. Since there were no memory barriers before, it was theoretically possible to observe an Inactive status with a LastSeenUtc set long before the connection last became inactive. There's also the possibility of tearing without a lock.

@@ -100,8 +100,11 @@ public partial class HttpConnectionContext : Microsoft.AspNetCore.Connections.Co
public System.Threading.SemaphoreSlim WriteLock { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
[System.Diagnostics.DebuggerStepThroughAttribute]
public System.Threading.Tasks.Task DisposeAsync(bool closeGracefully = false) { throw null; }
public void MarkInactive() { }
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 What's the deal with reference assemblies for pubternal classes? Do we really have to keep back compat? If so, should we just make everything new internal?

@halter73 halter73 added area-signalr Includes: SignalR clients and servers and removed area-servers labels Mar 6, 2019
@halter73
Copy link
Member Author

halter73 commented Mar 6, 2019

@BrennanConroy Ping.

Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

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

Still have a flaky test

@halter73 halter73 force-pushed the halter73/brecon/longpollrace branch 3 times, most recently from 102aa7b to 1810e77 Compare March 13, 2019 03:51
@halter73 halter73 force-pushed the halter73/brecon/longpollrace branch from da3caae to 03e65d5 Compare March 14, 2019 02:56
@halter73
Copy link
Member Author

@BrennanConroy I added the test.

Copy link
Member

@BrennanConroy BrennanConroy left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@halter73 halter73 merged commit 1338973 into master Mar 14, 2019
@halter73 halter73 deleted the halter73/brecon/longpollrace branch March 14, 2019 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants