+The bug was when a SLURM was successfully loaded, instead of stopping the interfal flow on success (a 'return' was needed) it continued to the error flow. This lead to worst errors later, such as segfault when a valid slurm was applied.
+Log error whenever the TALs configured directory is empty, log warning if the SLURM directory is empty.
}
static int
-process_dir_files(char const *location, char const *file_ext,
+process_dir_files(char const *location, char const *file_ext, bool empty_err,
process_file_cb cb, void *arg)
{
DIR *dir_loc;
error = -errno;
}
if (!error && found == 0)
- pr_op_warn("Location '%s' doesn't have files with extension '%s'",
- location, file_ext);
+ error = (empty_err ?
+ pr_op_err("Location '%s' doesn't have files with extension '%s'",
+ location, file_ext) :
+ pr_op_warn("Location '%s' doesn't have files with extension '%s'",
+ location, file_ext));
+
close_dir:
closedir(dir_loc);
end:
}
int
-process_file_or_dir(char const *location, char const *file_ext,
+process_file_or_dir(char const *location, char const *file_ext, bool empty_err,
process_file_cb cb, void *arg)
{
struct stat attr;
if (S_ISDIR(attr.st_mode) == 0)
return cb(location, arg);
- return process_dir_files(location, file_ext, cb, arg);
+ return process_dir_files(location, file_ext, empty_err, cb, arg);
}
void close_thread(pthread_t thread, char const *);
typedef int (*process_file_cb)(char const *, void *);
-int process_file_or_dir(char const *, char const *, process_file_cb, void *);
+int process_file_or_dir(char const *, char const *, bool, process_file_cb,
+ void *);
typedef int (*pr_errno_cb)(int, const char *, ...);
bool valid_file_or_dir(char const *, bool, bool, pr_errno_cb);
param->db = table;
param->threads = &threads;
- error = process_file_or_dir(config_get_tal(), TAL_FILE_EXTENSION,
+ error = process_file_or_dir(config_get_tal(), TAL_FILE_EXTENSION, true,
__do_file_validation, param);
if (error) {
/* End all threads */
params->db_slurm = db;
error = process_file_or_dir(config_get_slurm(), SLURM_FILE_EXTENSION,
- slurm_parse, params);
+ false, slurm_parse, params);
if (error) {
db_slurm_destroy(db);
params->db_slurm = NULL;
result.list_size = 0;
error = process_file_or_dir(config_get_slurm(), SLURM_FILE_EXTENSION,
- __slurm_load_checksums, &result);
+ false, __slurm_load_checksums, &result);
if (error) {
destroy_local_csum_list(&result);
return error;
*last_slurm = params->db_slurm;
+ return;
+
use_last_slurm:
/* Any error: use last valid SLURM */
pr_op_info("Error loading SLURM, the validation will still continue.");