From: pcarana Date: Tue, 7 Jan 2020 18:05:52 +0000 (-0600) Subject: Fix SLURM bugs and unitiliazed var warning. X-Git-Tag: v1.2.0~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aadbf61d96f010b06aea2483144bd9b86e7c5fd9;p=thirdparty%2FFORT-validator.git Fix SLURM bugs and unitiliazed var warning. +Initialize serial var when logging validation run information. +Use a write lock when removing non-visited tals RRDP info. +There was a segfault on two scenarios: - When run as server and using a slurm file, during the second run, the validator couldn't access RRDP data from the previous run. Fix: the RRDP TAL DB must be static (lives at the parent stack). - When SLURM was discarded due to a bad file content (eg. empty file, or malformed JSON) and during the next run the file content was valid again, the previous SLURM pointer was freed but didn't pointed at NULL (and this was expected). Fix: point at NULL when the whole SLURM is discarded. --- diff --git a/src/rrdp/db/db_rrdp.c b/src/rrdp/db/db_rrdp.c index 0935a540..d88d97ae 100644 --- a/src/rrdp/db/db_rrdp.c +++ b/src/rrdp/db/db_rrdp.c @@ -19,7 +19,9 @@ SLIST_HEAD(tal_list, tal_elem); struct db_rrdp { struct tal_list tals; -} db; +}; + +static struct db_rrdp db; /** Read/write lock, which protects @db. */ static pthread_rwlock_t lock; @@ -177,7 +179,7 @@ db_rrdp_rem_nonvisited_tals(void) { struct tal_elem *found; - rwlock_read_lock(&lock); + rwlock_write_lock(&lock); SLIST_FOREACH(found, &db.tals, next) { if (!found->visited) { SLIST_REMOVE(&db.tals, found, tal_elem, next); diff --git a/src/rtr/db/vrps.c b/src/rtr/db/vrps.c index 1aeb7815..2f978792 100644 --- a/src/rtr/db/vrps.c +++ b/src/rtr/db/vrps.c @@ -385,6 +385,7 @@ vrps_update(bool *changed) return __vrps_update(changed); pr_info("Starting validation."); + serial = START_SERIAL; if (config_get_mode() == SERVER) { error = get_last_serial_number(&serial); if (!error) diff --git a/src/slurm/slurm_loader.c b/src/slurm/slurm_loader.c index c65a4798..e1420bd8 100644 --- a/src/slurm/slurm_loader.c +++ b/src/slurm/slurm_loader.c @@ -173,6 +173,7 @@ slurm_apply(struct db_table **base, struct db_slurm **last_slurm) if (*last_slurm != NULL) { pr_info("Discarding previous valid SLURM"); db_slurm_destroy(*last_slurm); + *last_slurm = NULL; } goto success; }