summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-22 12:31:22 +0300
committerPaul Buetow <paul@buetow.org>2026-05-22 12:31:22 +0300
commitcb1e4376afe9f887b9e3b3b2a9ddef116bedb0cc (patch)
tree0f80808aca447c7a85581651c4b6d32cda13c7e0
parentcf855e1d0aa037a14abc0a889a5970cadca9805c (diff)
doc(rpn): clarify lock ordering in metric set handlers
No deadlock risk: evaluate() and RPN.SetPrefixMode() both acquire locks in the same order (r.mu → o.mu). The nested lock in evaluate() is safe — o.mu (Operations) is a separate mutex from r.mu (RPN). Resolves task ce: lock ordering analysis shows no circular wait.
-rw-r--r--internal/rpn/rpn_parse.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/internal/rpn/rpn_parse.go b/internal/rpn/rpn_parse.go
index 2d2963a..7abd41c 100644
--- a/internal/rpn/rpn_parse.go
+++ b/internal/rpn/rpn_parse.go
@@ -367,6 +367,9 @@ func (r *RPN) evaluate(input string, tokens []string) (string, error) {
return result, nil
case "binary":
if i+2 < len(tokens) && tokens[i+2] == "set" {
+ // Lock order: r.mu → o.mu (same as RPN.SetPrefixMode)
+ // No deadlock risk: both paths acquire in the same direction.
+ // r.mu is held by evaluate(); o.mu is a separate mutex on Operations.
r.prefixMode = IEC
r.ops.SetPrefixMode(IEC)
return "prefix mode: IEC", nil