summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 1841c42..b5cc758 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -40,7 +40,6 @@
#include <fastd_version.h>
#include <grp.h>
-#include <pthread.h>
#include <signal.h>
#include <syslog.h>
#include <sys/resource.h>
@@ -539,6 +538,15 @@ static inline void init(int argc, char *argv[]) {
ctx.next_maintenance = fastd_in_seconds(MAINTENANCE_INTERVAL);
ctx.unknown_handshakes[0].timeout = ctx.now;
+ VECTOR_ALLOC(ctx.eth_addrs, 0);
+ VECTOR_ALLOC(ctx.peers, 0);
+ VECTOR_ALLOC(ctx.async_pids, 0);
+
+ if (pthread_attr_init(&ctx.detached_thread))
+ exit_errno("pthread_attr_init");
+ if (pthread_attr_setdetachstate(&ctx.detached_thread, PTHREAD_CREATE_DETACHED))
+ exit_errno("pthread_attr_setdetachstate");
+
pr_info("fastd " FASTD_VERSION " starting");
fastd_cap_init();
@@ -558,10 +566,6 @@ static inline void init(int argc, char *argv[]) {
set_groups();
write_pid();
- VECTOR_ALLOC(ctx.eth_addrs, 0);
- VECTOR_ALLOC(ctx.peers, 0);
- VECTOR_ALLOC(ctx.async_pids, 0);
-
fastd_peer_hashtable_init();
#ifdef ENABLE_SYSTEMD
@@ -681,6 +685,8 @@ static inline void cleanup(void) {
fastd_peer_hashtable_free();
+ pthread_attr_destroy(&ctx.detached_thread);
+
VECTOR_FREE(ctx.async_pids);
VECTOR_FREE(ctx.peers);
VECTOR_FREE(ctx.eth_addrs);