From 72d35762571714b10fc18ec5e5de3c8468227721 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 30 Jan 2015 19:33:42 -0500 Subject: [PATCH] Fix a crash and a hang in the new computer manager code --- .../limelight/computers/ComputerManagerService.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/limelight/computers/ComputerManagerService.java b/app/src/main/java/com/limelight/computers/ComputerManagerService.java index 9af8808b..efccc028 100644 --- a/app/src/main/java/com/limelight/computers/ComputerManagerService.java +++ b/app/src/main/java/com/limelight/computers/ComputerManagerService.java @@ -508,7 +508,7 @@ public class ComputerManagerService extends Service { return false; } - return !thread.isInterrupted(); + return thread != null && !thread.isInterrupted(); } public void start() { @@ -553,7 +553,10 @@ public class ComputerManagerService extends Service { computer.rawAppList = appList; // Notify that the app list has been updated - listener.notifyComputerUpdated(computer); + // and ensure that the thread is still active + if (listener != null && thread != null) { + listener.notifyComputerUpdated(computer); + } } catch (IOException e) { e.printStackTrace(); } @@ -567,9 +570,7 @@ public class ComputerManagerService extends Service { if (thread != null) { thread.interrupt(); - try { - thread.join(); - } catch (InterruptedException e) {} + // Don't join here because we might be blocked on network I/O thread = null; }