1. (error) Fix the --work-offline flag.
It has been unused since commit
85478ff30ebc029abb0ded48de5b557f52a758e0.
2. (performance) Remove redundant fopen() and fclose() during
valid_file_or_dir().
If stat() is used instead of fstat(), there's no need to open and
close the file.
(Technically, it's no longer validating readabilty, but since the
validator downloads the files, read permission errors should be
extremely rare, and can be catched later.)
3. (fine) Remove return value from thread_pool_task_cb.
This wasn't a problem, but the return value was meaningless, and
no callers were using it.
valid_file_or_dir(char const *location, bool check_file, bool check_dir,
int (*error_fn)(int error, const char *format, ...))
{
- FILE *file;
struct stat attr;
bool is_file, is_dir;
bool result;
if (!check_file && !check_dir)
pr_crit("Wrong usage, at least one check must be 'true'.");
- result = false;
- file = fopen(location, "rb");
- if (file == NULL) {
+ if (stat(location, &attr) == -1) {
if (error_fn != NULL)
- error_fn(errno, "Could not open location '%s'",
- location);
+ error_fn(errno, "stat(%s) failed", location);
return false;
}
- if (fstat(fileno(file), &attr) == -1) {
- if (error_fn != NULL)
- error_fn(errno, "fstat(%s) failed", location);
- goto end;
- }
-
is_file = check_file && S_ISREG(attr.st_mode);
is_dir = check_dir && S_ISDIR(attr.st_mode);
(check_file && check_dir) ? "file or directory" :
(check_file) ? "file" : "directory");
-end:
- if (fclose(file) == -1)
- if (error_fn != NULL)
- error_fn(errno, "fclose() failed");
return result;
}
return rpki_config.server.backlog;
}
-bool
-config_get_work_offline(void)
-{
- return rpki_config.work_offline;
-}
-
unsigned int
config_get_validation_interval(void)
{
bool
config_get_rsync_enabled(void)
{
- return rpki_config.rsync.enabled;
+ return !rpki_config.work_offline && rpki_config.rsync.enabled;
}
unsigned int
bool
config_get_http_enabled(void)
{
- return rpki_config.http.enabled;
+ return !rpki_config.work_offline && rpki_config.http.enabled;
}
unsigned int
bool config_get_shuffle_tal_uris(void);
unsigned int config_get_max_cert_depth(void);
enum mode config_get_mode(void);
-bool config_get_work_offline(void);
char const *config_get_http_user_agent(void);
unsigned int config_get_http_connect_timeout(void);
unsigned int config_get_http_transfer_timeout(void);
}
}
-static void *
+static void
remove_from_root(void *arg)
{
struct rem_dirs *root_arg = arg;
pr_op_debug("Done removing dirs.");
free(dirs_arr);
- return NULL;
}
/*
setopt_str(handler->curl, CURLOPT_URL, uri);
setopt_writefunction(handler->curl, cb, arg);
- pr_val_debug("Doing HTTP GET to '%s'.", uri);
+ pr_val_debug("HTTP GET: %s", uri);
res = curl_easy_perform(handler->curl);
res2 = curl_easy_getinfo(handler->curl, CURLINFO_RESPONSE_CODE,
if (uri_is_rsync(uri)) {
if (!config_get_rsync_enabled()) {
validation_destroy(state);
- return 0; /* Soft error */
+ return 0; /* Try some other TAL URI */
}
error = rsync_download_files(uri, true, false);
} else /* HTTPS */ {
if (!config_get_http_enabled()) {
validation_destroy(state);
- return 0; /* Soft error */
+ return 0; /* Try some other TAL URI */
}
error = http_download_file(uri,
reqs_errors_log_uri(uri_get_global(uri)));
return handle_tal_uri(tal, uri, arg);
}
-static void *
+static void
do_file_validation(void *thread_arg)
{
struct validation_thread *thread = thread_arg;
working_repo_cleanup();
fnstack_cleanup();
thread->exit_status = error;
- return NULL;
}
static void
* were no errors, just return success; otherwise, return error code -EPERM.
*
* @data_updated will be true if:
- * - Delta files were processed
- * - Snapshot file was processed
- * - @uri was already visited at this cycle
+ * - Delta files were processed,
+ * - Snapshot file was processed,
+ * - or @uri was already visited at this cycle
*/
int
rrdp_load(struct rpki_uri *uri, bool *data_updated)
* The client socket threads' entry routine.
* @arg must be released.
*/
-static void *
+static void
client_thread_cb(void *arg)
{
struct pdu_metadata const *meta;
error = clients_add(param.fd, param.addr);
if (error) {
close(param.fd);
- return NULL;
+ return;
}
while (true) { /* For each PDU... */
}
clients_forget(param.fd, end_client, CL_CLOSED);
-
- return NULL;
}
static void
/*
* Waits for client connections and spawns threads to handle them.
*/
-static void *
+static void
handle_client_connections(void *arg)
{
struct sockaddr_storage client_addr;
case VERDICT_RETRY:
continue;
case VERDICT_EXIT:
- return NULL;
+ return;
}
/*
}
}
} while (true);
-
- return NULL;
}
static int
int thread_pool_create(char const *, unsigned int, struct thread_pool **);
void thread_pool_destroy(struct thread_pool *);
-typedef void *(*thread_pool_task_cb)(void *);
+typedef void (*thread_pool_task_cb)(void *);
int thread_pool_push(struct thread_pool *, char const *, thread_pool_task_cb,
void *);
#include "impersonator.c"
#include "thread/thread_pool.c"
-static void *
+static void
thread_work(void *arg)
{
int *value = arg;
(*value) += 2;
- return NULL;
}
static void