Browse Source

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 <pnmanjos@hotmail.com>
tags/2.3.1
Yeba GitHub 4 years ago
parent
commit
73e5cc2fbc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 4
- 4
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -245,15 +245,15 @@ namespace Discord.WebSocket
await _gatewayLogger.DebugAsync("Identifying").ConfigureAwait(false); await _gatewayLogger.DebugAsync("Identifying").ConfigureAwait(false);
await ApiClient.SendIdentifyAsync(shardID: ShardId, totalShards: TotalShards, guildSubscriptions: _guildSubscriptions, gatewayIntents: _gatewayIntents, presence: BuildCurrentStatus()).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 finally
{ {
if (locked) if (locked)
_shardedClient.ReleaseIdentifyLock(); _shardedClient.ReleaseIdentifyLock();
} }

//Wait for READY
await _connection.WaitAsync().ConfigureAwait(false);
} }
private async Task OnDisconnectingAsync(Exception ex) private async Task OnDisconnectingAsync(Exception ex)
{ {
@@ -632,7 +632,7 @@ namespace Discord.WebSocket
} }
else if (_connection.CancelToken.IsCancellationRequested) else if (_connection.CancelToken.IsCancellationRequested)
return; return;
if (BaseConfig.AlwaysDownloadUsers) if (BaseConfig.AlwaysDownloadUsers)
_ = DownloadUsersAsync(Guilds.Where(x => x.IsAvailable && !x.HasAllMembers)); _ = DownloadUsersAsync(Guilds.Where(x => x.IsAvailable && !x.HasAllMembers));




Loading…
Cancel
Save