Health_index (#6377)
Inside rrdcalc_unlink_and_free I wrote a not proper way to check the presence of an element inside the AVL, so I was raising an error without to do the correct checks!
thiagoftsm committed
Jul 5, 2019 at 10:45 UTC
80b70d37f26c9d310f71d7ab32bf4c8a228200f7
1 file changed
+12
-6
database/rrdcalc.c
+12
-6
@@ -438,14 +438,20 @@ void rrdcalc_unlink_and_free(RRDHOST *host, RRDCALC *rc) {
438
}
439
440
if (rc) {
441
- RRDCALC *rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_health_log, (avl *)rc);
442
- if (!rdcmp) {
443
- error("Cannot remove the health alarm index");
441
+ RRDCALC *rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_health_log, (avl *)rc);
442
+ if (rdcmp) {
443
+ rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_health_log, (avl *)rc);
444
+ if (!rdcmp) {
445
+ error("Cannot remove the health alarm index from health_log");
446
+ }
447
}
448
446
- rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_name, (avl *)rc);
447
- if (!rdcmp) {
448
- error("Cannot remove the health alarm index");
449
+ rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_name, (avl *)rc);
450
+ if (rdcmp) {
451
+ rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_name, (avl *)rc);
452
+ if (!rdcmp) {
453
+ error("Cannot remove the health alarm index from idx_name");
454
+ }
455
}
456
}
457