]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Use common function to get time, try to simplify previous SLURM loading
authorpcarana <pc.moreno2099@gmail.com>
Thu, 21 May 2020 04:23:20 +0000 (23:23 -0500)
committerpcarana <pc.moreno2099@gmail.com>
Thu, 21 May 2020 04:23:20 +0000 (23:23 -0500)
src/slurm/db_slurm.c
src/slurm/db_slurm.h
src/slurm/slurm_loader.c

index a47351071a700ede14a1407b59f10fba488143d8..2a962c0e66d1873a6c1819515357e6e426dcf650 100644 (file)
@@ -444,11 +444,17 @@ db_slurm_foreach_assertion_bgpsec(struct db_slurm *db, bgpsec_foreach_cb cb,
        return foreach_assertion_bgpsec(&db->lists, cb, arg);
 }
 
-void
+int
 db_slurm_update_time(struct db_slurm *db)
 {
-       db->loaded_date = time(NULL);
+       int error;
+
+       error = get_current_time(&db->loaded_date);
+       if (error)
+               return error;
+
        db->loaded_date_set = true;
+       return 0;
 }
 
 static int
index c644f8b350c2bc989439ba75df954d6f038207c7..65df53c2a1a7c52b86180bd9c188ca65f6df7a7e 100644 (file)
@@ -63,7 +63,7 @@ int db_slurm_foreach_assertion_bgpsec(struct db_slurm *, bgpsec_foreach_cb,
     void *);
 
 /* Set the last update to current datetime */
-void db_slurm_update_time(struct db_slurm *);
+int db_slurm_update_time(struct db_slurm *);
 /* Log the DB in human readable form at INFO level */
 void db_slurm_log(struct db_slurm *);
 
index 4bac7e8943f2a37efba04d7b706b9af309b6b50a..1912ea0886e5c1e17fede9b25a7e9e3dfdbf489c 100644 (file)
@@ -204,17 +204,15 @@ __load_slurm_files(struct db_slurm **last_slurm,
        int error;
 
        error = load_slurm_files(params);
-       if (error) {
-               /* Any error: use last valid SLURM */
-               pr_op_info("Error loading SLURM, the validation will still continue.");
-               if (*last_slurm != NULL) {
-                       pr_op_info("A previous valid version of the SLURM exists and will be applied.");
-                       params->db_slurm = *last_slurm;
-                       /* Log applied SLURM as info */
-                       db_slurm_log(params->db_slurm);
-               }
-               destroy_local_csum_list(csum_list);
-               return;
+       if (error)
+               goto use_last_slurm;
+
+       /* Prepare the new SLURM DB */
+       if (params->db_slurm != NULL) {
+               error = db_slurm_update_time(params->db_slurm);
+               if (error)
+                       goto use_last_slurm;
+               db_slurm_set_csum_list(params->db_slurm, csum_list);
        }
 
        /* Use new SLURM as last valid slurm */
@@ -222,10 +220,17 @@ __load_slurm_files(struct db_slurm **last_slurm,
                db_slurm_destroy(*last_slurm);
 
        *last_slurm = params->db_slurm;
+
+use_last_slurm:
+       /* Any error: use last valid SLURM */
+       pr_op_info("Error loading SLURM, the validation will still continue.");
        if (*last_slurm != NULL) {
-               db_slurm_update_time(*last_slurm);
-               db_slurm_set_csum_list(*last_slurm, csum_list);
+               pr_op_info("A previous valid version of the SLURM exists and will be applied.");
+               params->db_slurm = *last_slurm;
+               /* Log applied SLURM as info */
+               db_slurm_log(params->db_slurm);
        }
+       destroy_local_csum_list(csum_list);
 }
 
 static bool