summaryrefslogtreecommitdiffstats
path: root/health
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-27 18:46:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-27 18:46:20 +0000
commitc933bf105b0de89e3fd524517daf163a16dd0d44 (patch)
tree50cb525f946e4ac65a416178766e2e124167a40f /health
parentReleasing debian version 1.40.0-2. (diff)
downloadnetdata-c933bf105b0de89e3fd524517daf163a16dd0d44.tar.xz
netdata-c933bf105b0de89e3fd524517daf163a16dd0d44.zip
Merging upstream version 1.40.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health')
-rw-r--r--health/health.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/health/health.c b/health/health.c
index df4798a2..e04debb9 100644
--- a/health/health.c
+++ b/health/health.c
@@ -628,8 +628,9 @@ static inline void health_alarm_log_process(RRDHOST *host) {
//delete those that are updated, no in progress execution, and is not repeating
netdata_rwlock_wrlock(&host->health_log.alarm_log_rwlock);
- ALARM_ENTRY *prev = host->health_log.alarms;
- for(ae = host->health_log.alarms; ae ; ae = ae->next) {
+ ALARM_ENTRY *prev = NULL, *next = NULL;
+ for(ae = host->health_log.alarms; ae ; ae = next) {
+ next = ae->next; // set it here, for the next iteration
if((likely(!(ae->flags & HEALTH_ENTRY_FLAG_IS_REPEATING)) &&
(ae->flags & HEALTH_ENTRY_FLAG_UPDATED) &&
@@ -641,15 +642,19 @@ static inline void health_alarm_log_process(RRDHOST *host) {
(ae->when + 3600 < now_realtime_sec())))
{
- if (ae == host->health_log.alarms) {
- host->health_log.alarms = ae->next;
- prev = ae->next;
- } else {
- prev->next = ae->next;
+ if(host->health_log.alarms == ae) {
+ host->health_log.alarms = next;
+ // prev is also NULL here
+ }
+ else {
+ prev->next = next;
+ // prev should not be touched here - we need it for the next iteration
+ // because we may have to also remove the next item
}
+
health_alarm_log_free_one_nochecks_nounlink(ae);
- ae = prev;
- } else
+ }
+ else
prev = ae;
}