try solving a softlock

This commit is contained in:
Pilzinsel64
2025-01-28 06:52:00 +01:00
parent b05b18b1a6
commit f8bce850d5

View File

@@ -98,6 +98,8 @@ public class ApiServer(string apiUrl) : IApiServer
protected virtual void WaitForSlot()
{
if (MaxConcurentConnections == int.MaxValue)
return; // Unlimited in this case
semaphore ??= new(MaxConcurentConnections);
semaphore.Wait();
}
@@ -190,6 +192,7 @@ public class ApiServer(string apiUrl) : IApiServer
{
Log.Fatal($"Too many concurent connections", ex);
Thread.Sleep(1000);
FreeSlot();
return;
}
@@ -204,7 +207,10 @@ public class ApiServer(string apiUrl) : IApiServer
{
Log.Fatal($"Fatal http error retriving context with code {ex.ErrorCode}", ex);
if (AutoRestart()) // Try restart the server and skip this context
{
FreeSlot();
return;
}
}
else
Log.Error($"Http error retriving context with code {ex.ErrorCode}", ex);