Skip to content

Commit

Permalink
fix: Deadlock in DiscordShardedClient when Ready is never received (#…
Browse files Browse the repository at this point in the history
…1761)

* fixed a deadlock in DiscordShardedClient during a failed Identify due to InvalidSession

* fixed log

* Don't wait ready before releasing semaphore

Co-authored-by: Paulo <pnmanjos@hotmail.com>
  • Loading branch information
asmejkal and SubZero0 committed Jan 31, 2021
1 parent 83e88f4 commit 73e5cc2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Discord.Net.WebSocket/DiscordSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ private async Task OnConnectingAsync()
await _gatewayLogger.DebugAsync("Identifying").ConfigureAwait(false);
await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards, guildSubscriptions: _guildSubscriptions, gatewayIntents: _gatewayIntents, presence: BuildCurrentStatus()).ConfigureAwait(false);
}

//Wait for READY
await _connection.WaitAsync().ConfigureAwait(false);
}
finally
{
if (locked)
_shardedClient.ReleaseIdentifyLock();
}

//Wait for READY
await _connection.WaitAsync().ConfigureAwait(false);
}
private async Task OnDisconnectingAsync(Exception ex)
{
Expand Down Expand Up @@ -632,7 +632,7 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty
}
else if (_connection.CancelToken.IsCancellationRequested)
return;
if (BaseConfig.AlwaysDownloadUsers)
_ = DownloadUsersAsync(Guilds.Where(x => x.IsAvailable && !x.HasAllMembers));
Expand Down

0 comments on commit 73e5cc2

Please sign in to comment.