- Mandatory cgcc cleanup.
- Change the VRPS read-write lock into a mutex. (Because there
are no readers.)
- Remove `static` modifier from `rtrhandler_handle_roa_v4()`'s
helper functions (in the hopes of getting a slightly more
revealing stack trace).
Still haven't found the problem. It behaves like a concurrency
error, but doesn't look possible.
#include "config.h"
#include "log.h"
+void
+mutex_lock(pthread_mutex_t *lock)
+{
+ int error;
+
+ error = pthread_mutex_lock(lock);
+ if (error) {
+ pr_op_err("pthread_mutex_lock() returned error code %d. This is too critical for a graceful recovery; I must die now.",
+ error);
+ exit(error);
+ }
+}
+
+void
+mutex_unlock(pthread_mutex_t *lock)
+{
+ int error;
+
+ error = pthread_mutex_unlock(lock);
+ if (error) {
+ pr_op_err("pthread_mutex_unlock() returned error code %d. This is too critical for a graceful recovery; I must die now.",
+ error);
+ exit(error);
+ }
+}
+
int
rwlock_read_lock(pthread_rwlock_t *lock)
{
#define ARRAY_LEN(array) (sizeof(array) / sizeof((array)[0]))
/*
- * rwlock wrappers. They are just a bunch of boilerplate, and removal of
+ * mutex wrappers. They are just a bunch of boilerplate, and removal of
* unrecoverable resulting error codes.
*/
+void mutex_lock(pthread_mutex_t *);
+void mutex_unlock(pthread_mutex_t *);
int rwlock_read_lock(pthread_rwlock_t *);
void rwlock_write_lock(pthread_rwlock_t *);
void rwlock_unlock(pthread_rwlock_t *);
return 0;
}
-int
+static int
parse_argv_enabled(struct option_field const *field, char const *str,
void *result)
{
return set_rrdp_enabled(field->name, DEREFERENCE_BOOL(result));
}
-int
+static int
parse_json_enabled(struct option_field const *opt, struct json_t *json,
void *result)
{
return set_rrdp_enabled(opt->name, DEREFERENCE_BOOL(result));
}
-int
+static int
parse_argv_priority(struct option_field const *field, char const *str,
void *result)
{
return set_priority(field->name, DEREFERENCE_UINT32(result));
}
-int
+static int
parse_json_priority(struct option_field const *opt, json_t *json, void *result)
{
int error;
return set_priority(opt->name, DEREFERENCE_UINT32(result));
}
-int
+static int
parse_argv_retry_count(struct option_field const *field, char const *str,
void *result)
{
return set_retry_count(field->name, DEREFERENCE_UINT(result));
}
-int
+static int
parse_json_retry_count(struct option_field const *opt, json_t *json,
void *result)
{
return set_retry_count(opt->name, DEREFERENCE_UINT(result));
}
-int
+static int
parse_argv_retry_interval(struct option_field const *field, char const *str,
void *result)
{
return set_retry_interval(field->name, DEREFERENCE_UINT(result));
}
-int
+static int
parse_json_retry_interval(struct option_field const *opt, json_t *json,
void *result)
{
if (color_output)
fprintf(lvl->stream, "%s", lvl->color);
- now = time(0);
+ now = time(NULL);
if (now != ((time_t) -1)) {
localtime_r(&now, &stm_buff);
strftime(time_buff, sizeof(time_buff), "%b %e %T", &stm_buff);
if (color_output)
fprintf(lvl->stream, "%s", lvl->color);
- now = time(0);
+ now = time(NULL);
if (now != ((time_t) -1)) {
localtime_r(&now, &stm_buff);
strftime(time_buff, sizeof(time_buff), "%b %e %T", &stm_buff);
free(tal);
}
-int
+static int
foreach_uri(struct tal *tal, foreach_uri_cb cb, void *arg)
{
unsigned int i;
return 0;
}
-static struct hashable_roa *
+struct hashable_roa *
create_roa(uint32_t asn, uint8_t max_length)
{
struct hashable_roa *roa;
return roa;
}
-static int
+int
add_roa(struct db_table *table, struct hashable_roa *new)
{
struct hashable_roa *old;
static pthread_rwlock_t state_lock;
/** Lock to protect ROA table during construction. */
-static pthread_rwlock_t table_lock;
+static pthread_mutex_t table_lock;
void
deltagroup_cleanup(struct delta_group *group)
goto release_deltas;
}
- error = pthread_rwlock_init(&table_lock, NULL);
+ error = pthread_mutex_init(&table_lock, NULL);
if (error) {
error = pr_op_errno(error, "table pthread_rwlock_init() errored");
goto release_state_lock;
deltas_db_cleanup(&state.deltas, deltagroup_cleanup);
/* Nothing to do with error codes from now on */
pthread_rwlock_destroy(&state_lock);
- pthread_rwlock_destroy(&table_lock);
+ pthread_mutex_destroy(&table_lock);
}
-#define WLOCK_HANDLER(lock, cb) \
- int error; \
- rwlock_write_lock(lock); \
- error = cb; \
- rwlock_unlock(lock); \
- return error;
-
-#define RLOCK_HANDLER(lock, cb) \
- int error; \
- rwlock_read_lock(lock); \
- error = cb; \
- rwlock_unlock(lock); \
- return error;
-
int
handle_roa_v4(uint32_t as, struct ipv4_prefix const *prefix,
uint8_t max_length, void *arg)
{
- WLOCK_HANDLER(&table_lock,
- rtrhandler_handle_roa_v4(arg, as, prefix, max_length))
+ int error;
+ mutex_lock(&table_lock);
+ error = rtrhandler_handle_roa_v4(arg, as, prefix, max_length);
+ mutex_unlock(&table_lock);
+ return error;
}
int
handle_roa_v6(uint32_t as, struct ipv6_prefix const * prefix,
uint8_t max_length, void *arg)
{
- WLOCK_HANDLER(&table_lock,
- rtrhandler_handle_roa_v6(arg, as, prefix, max_length))
+ int error;
+ mutex_lock(&table_lock);
+ error = rtrhandler_handle_roa_v6(arg, as, prefix, max_length);
+ mutex_unlock(&table_lock);
+ return error;
}
int
handle_router_key(unsigned char const *ski, uint32_t as,
unsigned char const *spk, void *arg)
{
- WLOCK_HANDLER(&table_lock,
- rtrhandler_handle_router_key(arg, ski, as, spk))
+ int error;
+ mutex_lock(&table_lock);
+ error = rtrhandler_handle_router_key(arg, ski, as, spk);
+ mutex_unlock(&table_lock);
+ return error;
}
static int