summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-07-23 10:03:52 +0200
committerSimon Rettberg2020-07-23 10:03:52 +0200
commitc9df626bf2472174a442216d345cd2a89ec86d1b (patch)
tree7e6a9030fefb8bdbf34a46eac96f7240987fe521
parentUpdate client locationid in AvailableClient (diff)
downloadbwlp-guacamole-ext-c9df626bf2472174a442216d345cd2a89ec86d1b.tar.gz
bwlp-guacamole-ext-c9df626bf2472174a442216d345cd2a89ec86d1b.tar.xz
bwlp-guacamole-ext-c9df626bf2472174a442216d345cd2a89ec86d1b.zip
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.
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java20
1 files changed, 20 insertions, 0 deletions
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<Integer, JsonGroup> groupPool = new LinkedHashMap<Integer, JsonGroup>();
+ 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) {