]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Fix SLURM bugs and unitiliazed var warning.
authorpcarana <pc.moreno2099@gmail.com>
Tue, 7 Jan 2020 18:05:52 +0000 (12:05 -0600)
committerpcarana <pc.moreno2099@gmail.com>
Tue, 7 Jan 2020 18:05:52 +0000 (12:05 -0600)
+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.

src/rrdp/db/db_rrdp.c
src/rtr/db/vrps.c
src/slurm/slurm_loader.c

index 0935a5404bdbf8b61ff22d2dd6dfbc93845181d4..d88d97ae9be62d0d177027309c8eccd249b55220 100644 (file)
@@ -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);
index 1aeb7815400137df3c31555a796ce65c61771c84..2f9787921fd0c85e654f4f29f048580fd6e9c967 100644 (file)
@@ -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)
index c65a479839b275912166999a52fdc0d5bdffd866..e1420bd8fe97784fabc9e62fd5718795f8c4a973 100644 (file)
@@ -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;
        }