mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 20:17:22 +01:00
ignore queue semaphore when processing queue
This commit is contained in:
parent
b230f12508
commit
60f6bb5829
1 changed files with 3 additions and 7 deletions
|
|
@ -16,7 +16,6 @@ public class RequestQueueService : IHostedService
|
|||
private readonly int _queueExpirationSeconds;
|
||||
private SemaphoreSlim _queueSemaphore = new(1);
|
||||
private SemaphoreSlim _queueProcessingSemaphore = new(1);
|
||||
private bool _isProcessingQueue = false;
|
||||
private System.Timers.Timer _queueTimer;
|
||||
|
||||
public RequestQueueService(MareMetrics metrics, IConfigurationService<StaticFilesServerConfiguration> configurationService, ILogger<RequestQueueService> logger)
|
||||
|
|
@ -104,13 +103,12 @@ public class RequestQueueService : IHostedService
|
|||
|
||||
private async void ProcessQueue(object src, ElapsedEventArgs e)
|
||||
{
|
||||
if (_isProcessingQueue) return;
|
||||
if (_queueProcessingSemaphore.CurrentCount == 0) return;
|
||||
|
||||
await _queueProcessingSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
|
||||
_isProcessingQueue = true;
|
||||
try
|
||||
{
|
||||
await _queueProcessingSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
await _queueSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
for (int i = 0; i < _userQueueRequests.Length; i++)
|
||||
{
|
||||
if (_userQueueRequests[i] != null && !_userQueueRequests[i].IsActive && _userQueueRequests[i].ExpirationDate < DateTime.UtcNow) _userQueueRequests[i] = null;
|
||||
|
|
@ -134,11 +132,9 @@ public class RequestQueueService : IHostedService
|
|||
finally
|
||||
{
|
||||
_queueProcessingSemaphore.Release();
|
||||
_queueSemaphore.Release();
|
||||
}
|
||||
|
||||
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadQueue, _queue.Count);
|
||||
_isProcessingQueue = false;
|
||||
}
|
||||
|
||||
private void DequeueIntoSlot(UserRequest userRequest, int slot)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue