-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0046-Automation-synchronize-processActions-concurrent-pas.patch
More file actions
46 lines (41 loc) · 2.58 KB
/
Copy path0046-Automation-synchronize-processActions-concurrent-pas.patch
File metadata and controls
46 lines (41 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From ca93b59e70e49081db55e439200ba91f747f434b Mon Sep 17 00:00:00 2001
From: toniuhlemann <99549438+toniuhlemann@users.noreply.github.com>
Date: Mon, 13 Jul 2026 11:34:32 +0200
Subject: [PATCH 41/42] Automation: synchronize processActions (concurrent-pass
interleaving fix)
processActions() runs from two threads - the periodic refreshLoop on the
automation handler thread and the rx event subscriptions (BT/charging/
network/location) on the io scheduler. Unsynchronized, two passes could
interleave their action sequences (each action sleeps 3s, so the window
is wide). Live case 2026-07-13 08:21: an iobTH guard evaluated
MEAL_ACTIVE=false mid-way through a meal-boost event's action list and
its SetIobTH landed BETWEEN the boost's own actions, stomping the boost
threshold right at meal start. @Synchronized serializes complete passes;
a colliding trigger waits a few seconds and then evaluates against the
consistent post-pass state. Applies to stock AAPS as well (rarer there
with the 150s poll) - upstream candidate.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---
.../app/aaps/plugins/automation/AutomationPlugin.kt | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/AutomationPlugin.kt b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/AutomationPlugin.kt
index 13551be06a..c757bbef17 100644
--- a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/AutomationPlugin.kt
+++ b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/AutomationPlugin.kt
@@ -253,6 +253,15 @@ class AutomationPlugin @Inject constructor(
automationEvents.add(AutomationEventObject(injector).fromJSON(EMPTY_EVENT))
}
+ // IOB-Action patch 0046 (2026-07-13): processActions() is invoked from TWO threads — the
+ // refreshLoop on the automation handler thread AND the rx event subscriptions (BT/charging/
+ // network/location) on the io scheduler. Unsynchronized, two passes can interleave their
+ // action sequences (each action sleeps 3s, so the window is wide): live case 08:21 — an
+ // IOBTH guard evaluated MEAL_ACTIVE=false mid-way through a meal-boost event's action list
+ // and its SetIobTH landed BETWEEN the boost's actions, stomping the boost threshold.
+ // @Synchronized serializes complete passes; a colliding trigger waits a few seconds and
+ // then evaluates against the CONSISTENT post-pass state. Upstream-AAPS candidate.
+ @Synchronized
internal fun processActions() {
if (!config.appInitialized) return
/**
--
2.50.0.windows.1