summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-25 05:02:38 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-25 05:38:06 +0100
commita1733e23340d8a8017bee168459c95d1c20a39f8 (patch)
tree87b1c211898e3bd101544088ebb78bdc7b3068ba
parent39cad1bbbef547018ce231d307fcaab08c0aca28 (diff)
downloadfastd-a1733e23340d8a8017bee168459c95d1c20a39f8.tar
fastd-a1733e23340d8a8017bee168459c95d1c20a39f8.zip
main: reorder a few initialization calls to initialize as little as possible before we are sure we must
-rw-r--r--src/fastd.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 10fd0a3..5be7a61 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -871,16 +871,6 @@ static int daemonize(fastd_context_t *ctx) {
}
int main(int argc, char *argv[]) {
-#ifdef HAVE_LIBSODIUM
- sodium_init();
-#endif
-
-#ifdef USE_OPENSSL
- ERR_load_crypto_strings();
- OpenSSL_add_all_algorithms();
- OPENSSL_config(NULL);
-#endif
-
fastd_context_t ctx = {};
int status_fd = -1;
@@ -888,8 +878,6 @@ int main(int argc, char *argv[]) {
fastd_random_bytes(&ctx, &ctx.randseed, sizeof(ctx.randseed), false);
- init_pipes(&ctx);
-
fastd_config_t conf;
fastd_configure(&ctx, &conf, argc, argv);
ctx.conf = &conf;
@@ -913,6 +901,16 @@ int main(int argc, char *argv[]) {
init_log(&ctx);
+#ifdef HAVE_LIBSODIUM
+ sodium_init();
+#endif
+
+#ifdef USE_OPENSSL
+ ERR_load_crypto_strings();
+ OpenSSL_add_all_algorithms();
+ OPENSSL_config(NULL);
+#endif
+
fastd_config_check(&ctx, &conf);
update_time(&ctx);
@@ -930,6 +928,7 @@ int main(int argc, char *argv[]) {
/* change groups early as the can be relevant for file access (for PID file & log files) */
set_groups(&ctx);
+ init_pipes(&ctx);
init_sockets(&ctx);
if (!fastd_socket_handle_binds(&ctx))
@@ -1009,14 +1008,14 @@ int main(int argc, char *argv[]) {
free(ctx.eth_addr);
free(ctx.ifname);
- close_log(&ctx);
- fastd_config_release(&ctx, &conf);
-
#ifdef USE_OPENSSL
CONF_modules_free();
EVP_cleanup();
ERR_free_strings();
#endif
+ close_log(&ctx);
+ fastd_config_release(&ctx, &conf);
+
return 0;
}