-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Describe the bug
I was just looking at how groups are managed in Signalr and have not actually seen this happen. If a connection was disconnecting while something else was adding it to a group, would the following be possible?
Lines 47-51 are executed - The connection to add exists
Lines 299-300 are executed on another thread - The connection is removed from connection list and all groups
Line 53 is executed - The connection is added to the group but that connection is no longer in the connection list
aspnetcore/src/SignalR/server/Core/src/DefaultHubLifetimeManager.cs
Lines 47 to 53 in cfe6f52
var connection = _connections[connectionId]; | |
if (connection == null) | |
{ | |
return Task.CompletedTask; | |
} | |
_groups.Add(connection, groupName); |
aspnetcore/src/SignalR/server/Core/src/DefaultHubLifetimeManager.cs
Lines 297 to 302 in cfe6f52
public override Task OnDisconnectedAsync(HubConnectionContext connection) | |
{ | |
_connections.Remove(connection); | |
_groups.RemoveDisconnectedConnection(connection.ConnectionId); | |
return Task.CompletedTask; | |
} |
If this is an issue, would another check for _connections[connectionId] is null
after adding the connection to the group (after line 53) solve the issue?
To Reproduce
None
Exceptions (if any)
None
Further technical details
- ASP.NET Core version: 6