From 2d0af6281c57d46855c1d4aadf18a1e0ebb4f4c7 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 29 Dec 2017 14:05:29 -0800 Subject: [PATCH] Ensure polling threads terminate even when polling resumes immediately --- .../java/com/limelight/computers/ComputerManagerService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/limelight/computers/ComputerManagerService.java b/app/src/main/java/com/limelight/computers/ComputerManagerService.java index 0716b9b5..d588dd0e 100644 --- a/app/src/main/java/com/limelight/computers/ComputerManagerService.java +++ b/app/src/main/java/com/limelight/computers/ComputerManagerService.java @@ -134,7 +134,7 @@ public class ComputerManagerService extends Service { public void run() { int offlineCount = 0; - while (!isInterrupted() && pollingActive) { + while (!isInterrupted() && pollingActive && tuple.thread == this) { try { // Only allow one request to the machine at a time synchronized (tuple.networkLock) { @@ -392,6 +392,7 @@ public class ComputerManagerService extends Service { if (tuple.thread != null) { // Interrupt the thread on this entry tuple.thread.interrupt(); + tuple.thread = null; } pollingTuples.remove(tuple); break; @@ -840,6 +841,7 @@ public class ComputerManagerService extends Service { } while (waitPollingDelay()); } }; + thread.setName("App list polling thread for " + computer.localAddress); thread.start(); }