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