From 4dfef01f88c8647d732876bfbf36c5e9f9aad7fa Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Mon, 15 Jun 2020 16:51:10 +0200 Subject: [PATCH 1/2] Respect `ST_FLAG_IMMUTABLE` in `dstate_delinfo()` --- common/state.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/state.c b/common/state.c index ed9654d092..3fbcc2230f 100644 --- a/common/state.c +++ b/common/state.c @@ -141,6 +141,10 @@ int state_delinfo(st_tree_t **nptr, const char *var) continue; } + if (node->flags & ST_FLAG_IMMUTABLE) { + return 0; + } + /* whatever is on the left, hang it off current right */ st_tree_node_add(&node->right, node->left); From f5ffd2495b2c40cc37ef7e9a5e3a5bc4290b78ff Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 7 Oct 2020 16:57:58 +0200 Subject: [PATCH 2/2] state.c: state_delinfo(): comment on immutables For `state_delinfo()` not deleting immutable variables, comment this near the function and log for runtime hits to help troubleshooting. --- common/state.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/state.c b/common/state.c index 3fbcc2230f..93107114ff 100644 --- a/common/state.c +++ b/common/state.c @@ -124,7 +124,10 @@ static void st_tree_node_add(st_tree_t **nptr, st_tree_t *sptr) *nptr = sptr; } -/* remove a variable from a tree */ +/* remove a variable from a tree + * except for variables with ST_FLAG_IMMUTABLE + * (for override.* to survive) per issue #737 + */ int state_delinfo(st_tree_t **nptr, const char *var) { while (*nptr) { @@ -142,6 +145,7 @@ int state_delinfo(st_tree_t **nptr, const char *var) } if (node->flags & ST_FLAG_IMMUTABLE) { + upsdebugx(6, "%s: not deleting immutable variable [%s]", __func__, var); return 0; }