From: sofar Date: Tue, 5 Mar 2019 07:11:13 +0000 (-0800) Subject: getS16NoEx() returns true unless syntactical error in conf. (#8304) X-Git-Tag: 5.1.0~300 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=61e5fbab721898a431b15a5a7e24efb58cd80eb4;p=oweals%2Fminetest.git getS16NoEx() returns true unless syntactical error in conf. (#8304) The getS16NoEx() handler will return true unless there is a `[num_emerge_threads]` line in the `minetest.conf` at which point the excption handler part is reached. Due to the fact that `defaultsettings.cpp` has a default value set for this setting, that never will happen. Because of this, the code will never check the number of threads on the system, and keep `nthreads = 0`. If that happens, the value is changed to `1` and only 1 emerge thread will be used. The default should be set to `1` instead, due to the potential unsafe consequences for the standard sqlite map files, but that should be a separate commit that also adds documentation for that setting. This commit focuses on removing this `hiding` bug instead. --- diff --git a/src/emerge.cpp b/src/emerge.cpp index 592b1bef7..0ad6ee29b 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -130,11 +130,13 @@ EmergeManager::EmergeManager(Server *server) // If unspecified, leave a proc for the main thread and one for // some other misc thread - s16 nthreads = 0; - if (!g_settings->getS16NoEx("num_emerge_threads", nthreads)) + s16 nthreads; + g_settings->getS16NoEx("num_emerge_threads", nthreads); + if (nthreads == 0) nthreads = Thread::getNumberOfProcessors() - 2; if (nthreads < 1) nthreads = 1; + verbosestream << "Using " << nthreads << " emerge threads." << std::endl; m_qlimit_total = g_settings->getU16("emergequeue_limit_total"); if (!g_settings->getU16NoEx("emergequeue_limit_diskonly", m_qlimit_diskonly))