fix: Do not use unsafe work queue for auto archiving (#1116)
This commit is contained in:
parent
a4168dc219
commit
0d19a5ff99
2 changed files with 11 additions and 8 deletions
|
|
@ -119,7 +119,8 @@ public partial class Timer
|
||||||
{
|
{
|
||||||
RefillPool(amountToRefill, out var head, out var tail);
|
RefillPool(amountToRefill, out var head, out var tail);
|
||||||
return (head, tail);
|
return (head, tail);
|
||||||
}
|
},
|
||||||
|
Core.ClosingTokenSource.Token
|
||||||
);
|
);
|
||||||
|
|
||||||
ReturnToPool(amountToRefill, headTimer, tailTimer);
|
ReturnToPool(amountToRefill, headTimer, tailTimer);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Toolkit.HighPerformance;
|
using Microsoft.Toolkit.HighPerformance;
|
||||||
using Server.Compression;
|
using Server.Compression;
|
||||||
using Server.Logging;
|
using Server.Logging;
|
||||||
|
|
@ -218,7 +219,7 @@ namespace Server.Saves
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AutoArchiveLocally()
|
public static async void AutoArchiveLocally()
|
||||||
{
|
{
|
||||||
var date = Core.Now;
|
var date = Core.Now;
|
||||||
|
|
||||||
|
|
@ -232,22 +233,22 @@ namespace Server.Saves
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadPool.UnsafeQueueUserWorkItem(
|
ThreadPool.QueueUserWorkItem(
|
||||||
_ =>
|
now =>
|
||||||
{
|
{
|
||||||
if (date >= _nextHourlyArchive)
|
if (now >= _nextHourlyArchive)
|
||||||
{
|
{
|
||||||
Rollup(ArchivePeriod.Hourly);
|
Rollup(ArchivePeriod.Hourly);
|
||||||
_nextHourlyArchive = _nextHourlyArchive.AddHours(1);
|
_nextHourlyArchive = _nextHourlyArchive.AddHours(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date >= _nextDailyArchive)
|
if (now >= _nextDailyArchive)
|
||||||
{
|
{
|
||||||
Rollup(ArchivePeriod.Daily);
|
Rollup(ArchivePeriod.Daily);
|
||||||
_nextDailyArchive = _nextDailyArchive.AddDays(1);
|
_nextDailyArchive = _nextDailyArchive.AddDays(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date >= _nextMonthlyArchive)
|
if (now >= _nextMonthlyArchive)
|
||||||
{
|
{
|
||||||
Rollup(ArchivePeriod.Monthly);
|
Rollup(ArchivePeriod.Monthly);
|
||||||
_nextMonthlyArchive = _nextMonthlyArchive.AddMonths(1);
|
_nextMonthlyArchive = _nextMonthlyArchive.AddMonths(1);
|
||||||
|
|
@ -256,7 +257,8 @@ namespace Server.Saves
|
||||||
Prune?.Invoke();
|
Prune?.Invoke();
|
||||||
_isArchiving = 0;
|
_isArchiving = 0;
|
||||||
},
|
},
|
||||||
null
|
date,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue