Introducing the Big Tinc Lock.
[tinc] / src / tincd.c
index c4750da..9518676 100644 (file)
@@ -110,6 +110,8 @@ static struct option const long_options[] = {
        {NULL, 0, NULL, 0}
 };
 
+mutex_t mutex;
+
 #ifdef HAVE_MINGW
 static struct WSAData wsa_state;
 CRITICAL_SECTION mutex;
@@ -381,13 +383,11 @@ int main(int argc, char **argv) {
 
        openlogger("tinc", use_logfile?LOGMODE_FILE:LOGMODE_STDERR);
 
-       if(!event_init()) {
-               logger(LOG_ERR, "Error initializing libevent!");
-               return 1;
-       }
-
        g_argv = argv;
 
+       mutex_create(&mutex);
+       mutex_lock(&mutex);
+       init_events();
        init_configuration(&config_tree);
 
        /* Slllluuuuuuurrrrp! */
@@ -495,6 +495,7 @@ end:
        crypto_exit();
 
        exit_configuration(&config_tree);
+       exit_events();
        free_names();
 
        return status;