From 4c3e26d19c9ac97e790775f7e980d764d0b91e91 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 3 Dec 2017 20:10:54 +0100 Subject: [PATCH] R: resolve thread deadlock during bolus stop --- .../plugins/PumpDanaR/services/DanaRExecutionService.java | 2 +- .../info/nightscout/androidaps/queue/CommandQueue.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java index a025e1fc61..a7da6b600e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java @@ -433,7 +433,7 @@ public class DanaRExecutionService extends Service { } final Object o = new Object(); - ConfigBuilderPlugin.getCommandQueue().readStatus("bolusingInterrupted", new Callback() { + ConfigBuilderPlugin.getCommandQueue().independentConnect("bolusingInterrupted", new Callback() { @Override public void run() { if (danaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index 44e3f5f791..eea2635ae7 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -135,6 +135,13 @@ public class CommandQueue { } } + public static void independentConnect(String reason, Callback callback) { + CommandQueue tempCommandQueue = new CommandQueue(); + tempCommandQueue.readStatus(reason, callback); + QueueThread tempThread = new QueueThread(tempCommandQueue); + tempThread.start(); + } + // returns true if command is queued public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) { if (isRunning(Command.CommandType.BOLUS)) {