mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Don't stack threads in OnHeartBeat()
OnHeartBeat() is the least important function that is called every minute if required, not being able to enter the semaphore means some other action is already in progress, and while it makes sense for stuff like OnPersonaState() to wait for it, because it requires that, heartbeat can totally miss being executed, especially if the previous call didn't manage to finish yet. It's not destructive as it is right now because tasks would be cancelled eventually when the server starts responding (due to if being removed right now), but it's entirely unnecessary burden.
This commit is contained in:
@@ -105,13 +105,11 @@ namespace ArchiSteamFarm.Core {
|
||||
return;
|
||||
}
|
||||
|
||||
await RequestsSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
if (!await RequestsSemaphore.WaitAsync(0).ConfigureAwait(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!ShouldSendHeartBeats || (DateTime.UtcNow < LastHeartBeat.AddMinutes(MinHeartBeatTTL))) {
|
||||
return;
|
||||
}
|
||||
|
||||
Uri request = new($"{URL}/Api/HeartBeat");
|
||||
|
||||
Dictionary<string, string> data = new(2, StringComparer.Ordinal) {
|
||||
|
||||
Reference in New Issue
Block a user