From f8bce850d57859d37e02add890ae738858ace722 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Tue, 28 Jan 2025 06:52:00 +0100 Subject: [PATCH] try solving a softlock --- Pilz.Net/Api/ApiServer.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Pilz.Net/Api/ApiServer.cs b/Pilz.Net/Api/ApiServer.cs index ae8dd5d..5557680 100644 --- a/Pilz.Net/Api/ApiServer.cs +++ b/Pilz.Net/Api/ApiServer.cs @@ -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);