From 98848b61eca78a946f625499893aa2bf24942ae9 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 5 Sep 2017 22:47:10 +0200 Subject: [PATCH] send max 30 at once to NS --- .../plugins/NSClientInternal/services/NSClientService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index cbc18acbca..d171f87fc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -684,10 +684,11 @@ public class NSClientService extends Service { MainApp.bus().post(new EventNSClientNewLog("QUEUE", "Resend started: " + reason)); CloseableIterator iterator = null; + int maxcount = 30; try { iterator = MainApp.getDbHelper().getDbRequestInterator(); try { - while (iterator.hasNext()) { + while (iterator.hasNext() && maxcount > 0) { DbRequest dbr = iterator.next(); if (dbr.action.equals("dbAdd")) { NSAddAck addAck = new NSAddAck(); @@ -702,6 +703,7 @@ public class NSClientService extends Service { NSUpdateAck updateUnsetAck = new NSUpdateAck(dbr.action, dbr._id); dbUpdateUnset(dbr, updateUnsetAck); } + maxcount--; } } finally { iterator.close();