*
* However, fprintf and syslog are rarely enabled at the same time, so I don't
* think it's worth it. So I'm reusing the lock.
+ *
+ * "log" + "lock" = "logck"
*/
-static pthread_mutex_t lock;
+static pthread_mutex_t logck;
/**
* Important: -rdynamic needs to be enabled, otherwise this does not print
init_config(&op_config);
init_config(&val_config);
- error = pthread_mutex_init(&lock, NULL);
+ error = pthread_mutex_init(&logck, NULL);
if (error) {
fprintf(ERR.stream, "pthread_mutex_init() returned %d: %s\n",
error, strerror(abs(error)));
log_teardown(void)
{
log_disable_syslog();
- pthread_mutex_destroy(&lock);
+ pthread_mutex_destroy(&logck);
}
void
{
int error;
- error = pthread_mutex_lock(&lock);
+ error = pthread_mutex_lock(&logck);
if (error) {
/*
* Despite being supposed to be impossible, failing to lock the
{
int error;
- error = pthread_mutex_unlock(&lock);
+ error = pthread_mutex_unlock(&logck);
if (error)
print_stack_trace(strerror(error)); /* Same as above. */
}
# Unit Tests
-Run with
+You need `check` installed:
+
+ sudo apt install check
+
+Note: If you hadn't installed `check` when you ran `autogen.sh`, you will need to
+run it again:
+
+ cd ..
+ ./autogen.sh
+ ./configure
+
+Run the tests with
make check
return INAC_ERROR;
}
-void print_stack_trace(void)
-{
- /* Nothing needed here */
-}
-
/* Impersonate HTTP config */
char const *
config_get_http_user_agent(void)
send_error_report_pdu(int fd, uint8_t version, uint16_t code,
struct rtr_request const *request, char *message)
{
- pr_op_info(" Server sent Error Report %u: '%s'", code, message);
+ pr_op_info(" Server sent Error Report %u: '%s'", code,
+ /* gcc is complaining about logging NULL messages. WTF */
+ (message != NULL) ? message : "");
return 0;
}
int i;
int error;
- error = thread_pool_create(total_threads, &pool);
+ error = thread_pool_create("test pool", total_threads, &pool);
ck_assert_int_eq(error, 0);
/* Just a dummy array where each thread will modify one slot only */
data[i] = malloc(sizeof(int));
ck_assert_ptr_ne(data[i], NULL);
*data[i] = 0;
- thread_pool_push(pool, thread_work, data[i]);
+ thread_pool_push(pool, "test task", thread_work, data[i]);
}
/* Wait for all to finish (~2 sec) */