mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Fix rare restart issue
This commit is contained in:
@@ -148,7 +148,7 @@ namespace ArchiSteamFarm {
|
||||
bool? isLoggedIn = await IsLoggedIn().ConfigureAwait(false);
|
||||
if (isLoggedIn.HasValue && !isLoggedIn.Value) {
|
||||
Logging.LogGenericInfo("Reconnecting because our sessionID expired!", Bot.BotName);
|
||||
Task.Run(async () => await Bot.Restart().ConfigureAwait(false)).Forget();
|
||||
Task.Run(async () => await Bot.RestartIfRunning().ConfigureAwait(false)).Forget();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,11 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task Restart() {
|
||||
internal async Task RestartIfRunning() {
|
||||
if (!SteamClient.IsConnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
await Stop().ConfigureAwait(false);
|
||||
await Start().ConfigureAwait(false);
|
||||
}
|
||||
@@ -1563,7 +1567,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
if (!await ArchiWebHandler.Init(SteamClient, callback.WebAPIUserNonce, BotConfig.SteamParentalPIN).ConfigureAwait(false)) {
|
||||
await Restart().ConfigureAwait(false);
|
||||
await RestartIfRunning().ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace ArchiSteamFarm {
|
||||
private readonly Bot Bot;
|
||||
private readonly Timer Timer;
|
||||
|
||||
private bool ManualMode, NowFarming;
|
||||
private volatile bool ManualMode, NowFarming;
|
||||
|
||||
internal CardsFarmer(Bot bot) {
|
||||
if (bot == null) {
|
||||
@@ -178,10 +178,16 @@ namespace ArchiSteamFarm {
|
||||
|
||||
Logging.LogGenericInfo("Sending signal to stop farming", Bot.BotName);
|
||||
FarmResetEvent.Set();
|
||||
for (byte i = 0; i < 5 && NowFarming; i++) {
|
||||
Logging.LogGenericInfo("Waiting for reaction...", Bot.BotName);
|
||||
|
||||
Logging.LogGenericInfo("Waiting for reaction...", Bot.BotName);
|
||||
for (byte i = 0; i < Program.GlobalConfig.HttpTimeout && NowFarming; i++) {
|
||||
await Utilities.SleepAsync(1000).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (NowFarming) {
|
||||
Logging.LogGenericWarning("Timed out!", Bot.BotName);
|
||||
}
|
||||
|
||||
FarmResetEvent.Reset();
|
||||
Logging.LogGenericInfo("Farming stopped!", Bot.BotName);
|
||||
Semaphore.Release();
|
||||
|
||||
Reference in New Issue
Block a user