From 73e5cc2fbcc7c974706165f5cb0703770a0be727 Mon Sep 17 00:00:00 2001 From: Yeba <31899118+yebafan@users.noreply.github.com> Date: Sun, 31 Jan 2021 07:13:09 +0100 Subject: [PATCH] fix: Deadlock in DiscordShardedClient when Ready is never received (#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 --- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index d4c96ab26..b43db5d98 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -245,15 +245,15 @@ namespace Discord.WebSocket 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) { @@ -632,7 +632,7 @@ namespace Discord.WebSocket } else if (_connection.CancelToken.IsCancellationRequested) return; - + if (BaseConfig.AlwaysDownloadUsers) _ = DownloadUsersAsync(Guilds.Where(x => x.IsAvailable && !x.HasAllMembers));