try solving a softlock
This commit is contained in:
@@ -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,8 +207,11 @@ 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);
|
||||
context = null;
|
||||
|
||||
Reference in New Issue
Block a user