From cc0c35267f8fac4f82622ff73474ed1e2d3a1e36 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 21 Jul 2012 14:19:23 +0200 Subject: [PATCH] Call event_init() after detaching. Otherwise, the call to daemon() could close filedescriptors in use by libevent itself; for example if it uses kqueue or epoll instead of a select() or poll() backend. --- src/tincd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tincd.c b/src/tincd.c index 3cbac4ba..9f65bbea 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -382,11 +382,6 @@ int main(int argc, char **argv) { openlogger("tinc", use_logfile?LOGMODE_FILE:LOGMODE_STDERR); - if(!event_init()) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error initializing libevent!"); - return 1; - } - g_argv = argv; if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid()) @@ -439,6 +434,11 @@ int main2(int argc, char **argv) { } #endif + if(!event_init()) { + logger(DEBUG_ALWAYS, LOG_ERR, "Error initializing libevent!"); + return 1; + } + /* Setup sockets and open device. */ if(!setup_network()) -- 2.20.1