aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-06-23 15:22:31 +0200
committerGitHub <noreply@github.com>2021-06-23 15:22:31 +0200
commitc60a146e2291f7a55a3e5fd0447bd393b063ab1c (patch)
tree7a0810ef78f43866eb899145d6afdb36d99f2720 /src/main.cpp
parentcec0dfcbbda1e11e5ff2f45e58ea393d0437d7c6 (diff)
downloadminetest-c60a146e2291f7a55a3e5fd0447bd393b063ab1c.tar.gz
minetest-c60a146e2291f7a55a3e5fd0447bd393b063ab1c.tar.bz2
minetest-c60a146e2291f7a55a3e5fd0447bd393b063ab1c.zip
Rework Settings to support arbitrary hierarchies (#11352)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4a69f83b5..ffbdb7b5b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -91,6 +91,7 @@ static void list_worlds(bool print_name, bool print_path);
static bool setup_log_params(const Settings &cmd_args);
static bool create_userdata_path();
static bool init_common(const Settings &cmd_args, int argc, char *argv[]);
+static void uninit_common();
static void startup_message();
static bool read_config_file(const Settings &cmd_args);
static void init_log_streams(const Settings &cmd_args);
@@ -201,6 +202,7 @@ int main(int argc, char *argv[])
errorstream << "Unittest support is not enabled in this binary. "
<< "If you want to enable it, compile project with BUILD_UNITTESTS=1 flag."
<< std::endl;
+ return 1;
#endif
}
#endif
@@ -236,9 +238,6 @@ int main(int argc, char *argv[])
print_modified_quicktune_values();
- // Stop httpfetch thread (if started)
- httpfetch_cleanup();
-
END_DEBUG_EXCEPTION_HANDLER
return retval;
@@ -486,13 +485,14 @@ static bool init_common(const Settings &cmd_args, int argc, char *argv[])
startup_message();
set_default_settings();
- // Initialize sockets
sockets_init();
- atexit(sockets_cleanup);
// Initialize g_settings
Settings::createLayer(SL_GLOBAL);
+ // Set cleanup callback(s) to run at process exit
+ atexit(uninit_common);
+
if (!read_config_file(cmd_args))
return false;
@@ -511,6 +511,17 @@ static bool init_common(const Settings &cmd_args, int argc, char *argv[])
return true;
}
+static void uninit_common()
+{
+ httpfetch_cleanup();
+
+ sockets_cleanup();
+
+ // It'd actually be okay to leak these but we want to please valgrind...
+ for (int i = 0; i < (int)SL_TOTAL_COUNT; i++)
+ delete Settings::getLayer((SettingsLayer)i);
+}
+
static void startup_message()
{
infostream << PROJECT_NAME << " " << _("with")