diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-27 18:46:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-27 18:46:10 +0000 |
commit | 9abec302a4736c965a34b930f4f5bf2b1494bf6e (patch) | |
tree | aef24838cdda26750d86362b832263f4bcdf5a0e /health/health.c | |
parent | Adding upstream version 1.40.0. (diff) | |
download | netdata-9abec302a4736c965a34b930f4f5bf2b1494bf6e.tar.xz netdata-9abec302a4736c965a34b930f4f5bf2b1494bf6e.zip |
Adding upstream version 1.40.1.upstream/1.40.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health/health.c')
-rw-r--r-- | health/health.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/health/health.c b/health/health.c index df4798a20..e04debb93 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; } |