From c9df626bf2472174a442216d345cd2a89ec86d1b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 23 Jul 2020 10:03:52 +0200 Subject: Update client list every 2 mins for better timeout handling AvailableClient.isTimeout() is only called when the list is updated, which might be very infrequently. Some of its checks are better run frequently, as to not accidentally kill a connection to early. --- .../de/bwlehrpool/bwlp_guac/ConnectionManager.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java b/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java index 01bf2fc..7e64926 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java @@ -56,6 +56,26 @@ public class ConnectionManager { */ private static final LinkedHashMap groupPool = new LinkedHashMap(); + private static final Thread listUpdater; + + static { + listUpdater = new Thread() { + @Override + public void run() { + for (;;) { + try { + Thread.sleep(120000); + updateList(); + } catch (InterruptedException e) { + LOGGER.info("Stopping list fetch thread"); + return; + } + } + } + }; + listUpdater.setDaemon(true); + listUpdater.start(); + } public static JsonGroup getGroup(int id) { synchronized (clientPool) { -- cgit v1.2.3-55-g7522