aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/apply_permutation.h4
-rw-r--r--src/common/base58.cpp2
-rw-r--r--src/common/base58.h2
-rw-r--r--src/common/boost_serialization_helper.h2
-rw-r--r--src/common/command_line.cpp2
-rw-r--r--src/common/command_line.h2
-rw-r--r--src/common/common_fwd.h2
-rw-r--r--src/common/dns_utils.cpp2
-rw-r--r--src/common/dns_utils.h2
-rw-r--r--src/common/download.cpp2
-rw-r--r--src/common/download.h2
-rw-r--r--src/common/http_connection.h2
-rw-r--r--src/common/i18n.cpp2
-rw-r--r--src/common/i18n.h2
-rw-r--r--src/common/int-util.h2
-rw-r--r--src/common/json_util.h2
-rw-r--r--src/common/password.cpp2
-rw-r--r--src/common/password.h2
-rw-r--r--src/common/perf_timer.cpp81
-rw-r--r--src/common/perf_timer.h12
-rw-r--r--src/common/pod-class.h2
-rw-r--r--src/common/rpc_client.h18
-rw-r--r--src/common/scoped_message_writer.h2
-rw-r--r--src/common/sfinae_helpers.h2
-rw-r--r--src/common/stack_trace.cpp2
-rw-r--r--src/common/stack_trace.h2
-rw-r--r--src/common/threadpool.cpp2
-rw-r--r--src/common/threadpool.h2
-rw-r--r--src/common/unordered_containers_boost_serialization.h2
-rw-r--r--src/common/updates.cpp2
-rw-r--r--src/common/updates.h2
-rw-r--r--src/common/util.cpp29
-rw-r--r--src/common/util.h2
-rw-r--r--src/common/varint.h2
35 files changed, 143 insertions, 61 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 7ce0229da..66fd8d7ad 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2017, The Monero Project
+# Copyright (c) 2014-2018, The Monero Project
#
# All rights reserved.
#
diff --git a/src/common/apply_permutation.h b/src/common/apply_permutation.h
index 4fd952686..ff346bab1 100644
--- a/src/common/apply_permutation.h
+++ b/src/common/apply_permutation.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
@@ -30,6 +30,8 @@
// This algorithm is adapted from Raymond Chen's code:
// https://blogs.msdn.microsoft.com/oldnewthing/20170109-00/?p=95145
+#pragma once
+
#include <vector>
#include <functional>
#include "misc_log_ex.h"
diff --git a/src/common/base58.cpp b/src/common/base58.cpp
index 941373443..75556cad9 100644
--- a/src/common/base58.cpp
+++ b/src/common/base58.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/base58.h b/src/common/base58.h
index 6dd850c03..02ca96956 100644
--- a/src/common/base58.h
+++ b/src/common/base58.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/boost_serialization_helper.h b/src/common/boost_serialization_helper.h
index f8b21c52e..3f5c623f8 100644
--- a/src/common/boost_serialization_helper.h
+++ b/src/common/boost_serialization_helper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp
index 4b9ca9559..7980b381f 100644
--- a/src/common/command_line.cpp
+++ b/src/common/command_line.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/command_line.h b/src/common/command_line.h
index c2bac9cc8..7b183d86b 100644
--- a/src/common/command_line.h
+++ b/src/common/command_line.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/common_fwd.h b/src/common/common_fwd.h
index f33e185b5..2924d9cbe 100644
--- a/src/common/common_fwd.h
+++ b/src/common/common_fwd.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index d942ae9d0..06f127c25 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/dns_utils.h b/src/common/dns_utils.h
index c0a2dbf2b..d5dc03283 100644
--- a/src/common/dns_utils.h
+++ b/src/common/dns_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/download.cpp b/src/common/download.cpp
index 87814fa5e..6698a5abf 100644
--- a/src/common/download.cpp
+++ b/src/common/download.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/download.h b/src/common/download.h
index 917cb2278..3097394bc 100644
--- a/src/common/download.h
+++ b/src/common/download.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/http_connection.h b/src/common/http_connection.h
index 0357a90a0..9fc6be261 100644
--- a/src/common/http_connection.h
+++ b/src/common/http_connection.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/i18n.cpp b/src/common/i18n.cpp
index 28a186bf0..4a89876fb 100644
--- a/src/common/i18n.cpp
+++ b/src/common/i18n.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/i18n.h b/src/common/i18n.h
index 5169cf9f7..d21d00275 100644
--- a/src/common/i18n.h
+++ b/src/common/i18n.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/int-util.h b/src/common/int-util.h
index 6207997fe..3bcc085e2 100644
--- a/src/common/int-util.h
+++ b/src/common/int-util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/json_util.h b/src/common/json_util.h
index 45046a4fb..661022a6f 100644
--- a/src/common/json_util.h
+++ b/src/common/json_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016, The Monero Project
+// Copyright (c) 2016-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/password.cpp b/src/common/password.cpp
index 011123300..ef026c979 100644
--- a/src/common/password.cpp
+++ b/src/common/password.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/password.h b/src/common/password.h
index 01c6bf05a..7c29effe4 100644
--- a/src/common/password.h
+++ b/src/common/password.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/perf_timer.cpp b/src/common/perf_timer.cpp
index 4947058d3..41e23130d 100644
--- a/src/common/perf_timer.cpp
+++ b/src/common/perf_timer.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016, The Monero Project
+// Copyright (c) 2016-2018, The Monero Project
//
// All rights reserved.
//
@@ -33,6 +33,52 @@
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "perf"
+namespace
+{
+ uint64_t get_tick_count()
+ {
+#if defined(__x86_64__)
+ uint32_t hi, lo;
+ __asm__ volatile("rdtsc" : "=a"(lo), "=d"(hi));
+ return (((uint64_t)hi) << 32) | (uint64_t)lo;
+#else
+ return epee::misc_utils::get_ns_count();
+#endif
+ }
+
+#ifdef __x86_64__
+ uint64_t get_ticks_per_ns()
+ {
+ uint64_t t0 = epee::misc_utils::get_ns_count();
+ uint64_t r0 = get_tick_count();
+
+ while (1)
+ {
+ uint64_t t = epee::misc_utils::get_ns_count();
+ if (t - t0 > 1*1000000000) break; // work one second
+ }
+
+ uint64_t t1 = epee::misc_utils::get_ns_count();
+ uint64_t r1 = get_tick_count();
+ uint64_t tpns256 = 256 * (r1 - r0) / (t1 - t0);
+ return tpns256 ? tpns256 : 1;
+ }
+#endif
+
+#ifdef __x86_64__
+ uint64_t ticks_per_ns = get_ticks_per_ns();
+#endif
+
+ uint64_t ticks_to_ns(uint64_t ticks)
+ {
+#if defined(__x86_64__)
+ return 256 * ticks / ticks_per_ns;
+#else
+ return ticks;
+#endif
+ }
+}
+
namespace tools
{
@@ -51,9 +97,9 @@ void set_performance_timer_log_level(el::Level level)
performance_timer_log_level = level;
}
-PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Level l): name(s), unit(unit), level(l), started(false)
+PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Level l): name(s), unit(unit), level(l), started(false), paused(false)
{
- ticks = epee::misc_utils::get_ns_count();
+ ticks = get_tick_count();
if (!performance_timers)
{
MLOG(level, "PERF ----------");
@@ -62,9 +108,10 @@ PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Leve
else
{
PerformanceTimer *pt = performance_timers->back();
- if (!pt->started)
+ if (!pt->started && !pt->paused)
{
- MLOG(pt->level, "PERF " << std::string((performance_timers->size()-1) * 2, ' ') << " " << pt->name);
+ size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused) ++size;
+ MLOG(pt->level, "PERF " << std::string((size-1) * 2, ' ') << " " << pt->name);
pt->started = true;
}
}
@@ -74,10 +121,12 @@ PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Leve
PerformanceTimer::~PerformanceTimer()
{
performance_timers->pop_back();
- ticks = epee::misc_utils::get_ns_count() - ticks;
+ if (!paused)
+ ticks = get_tick_count() - ticks;
char s[12];
- snprintf(s, sizeof(s), "%8llu ", (unsigned long long)ticks / (1000000000 / unit));
- MLOG(level, "PERF " << s << std::string(performance_timers->size() * 2, ' ') << " " << name);
+ snprintf(s, sizeof(s), "%8llu ", (unsigned long long)(ticks_to_ns(ticks) / (1000000000 / unit)));
+ size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused || tmp==this) ++size;
+ MLOG(level, "PERF " << s << std::string(size * 2, ' ') << " " << name);
if (performance_timers->empty())
{
delete performance_timers;
@@ -85,4 +134,20 @@ PerformanceTimer::~PerformanceTimer()
}
}
+void PerformanceTimer::pause()
+{
+ if (paused)
+ return;
+ ticks = get_tick_count() - ticks;
+ paused = true;
+}
+
+void PerformanceTimer::resume()
+{
+ if (!paused)
+ return;
+ ticks = get_tick_count() - ticks;
+ paused = false;
+}
+
}
diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h
index a1d71609c..0e910caf9 100644
--- a/src/common/perf_timer.h
+++ b/src/common/perf_timer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016, The Monero Project
+// Copyright (c) 2016-2018, The Monero Project
//
// All rights reserved.
//
@@ -30,6 +30,7 @@
#include <string>
#include <stdio.h>
+#include <memory>
#include "misc_log_ex.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
@@ -47,6 +48,8 @@ class PerformanceTimer
public:
PerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug);
~PerformanceTimer();
+ void pause();
+ void resume();
private:
std::string name;
@@ -54,6 +57,7 @@ private:
el::Level level;
uint64_t ticks;
bool started;
+ bool paused;
};
void set_performance_timer_log_level(el::Level level);
@@ -62,8 +66,10 @@ void set_performance_timer_log_level(el::Level level);
#define PERF_TIMER_UNIT_L(name, unit, l) tools::PerformanceTimer pt_##name(#name, unit, l)
#define PERF_TIMER(name) PERF_TIMER_UNIT(name, 1000)
#define PERF_TIMER_L(name, l) PERF_TIMER_UNIT_L(name, 1000, l)
-#define PERF_TIMER_START_UNIT(name, unit) tools::PerformanceTimer *pt_##name = new tools::PerformanceTimer(#name, unit, el::Level::Info)
+#define PERF_TIMER_START_UNIT(name, unit) std::unique_ptr<tools::PerformanceTimer> pt_##name(new tools::PerformanceTimer(#name, unit, el::Level::Info))
#define PERF_TIMER_START(name) PERF_TIMER_START_UNIT(name, 1000)
-#define PERF_TIMER_STOP(name) do { delete pt_##name; pt_##name = NULL; } while(0)
+#define PERF_TIMER_STOP(name) do { pt_##name.reset(NULL); } while(0)
+#define PERF_TIMER_PAUSE(name) pt_##name->pause()
+#define PERF_TIMER_RESUME(name) pt_##name->resume()
}
diff --git a/src/common/pod-class.h b/src/common/pod-class.h
index 3896d5c29..5f6709eef 100644
--- a/src/common/pod-class.h
+++ b/src/common/pod-class.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/rpc_client.h b/src/common/rpc_client.h
index 297020ef2..9665966ae 100644
--- a/src/common/rpc_client.h
+++ b/src/common/rpc_client.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
@@ -72,10 +72,10 @@ namespace tools
fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port();
return false;
}
- ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
+ ok = epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
if (!ok)
{
- fail_msg_writer() << "Daemon request failed";
+ fail_msg_writer() << "basic_json_rpc_request: Daemon request failed";
return false;
}
else
@@ -95,15 +95,15 @@ namespace tools
t_http_connection connection(&m_http_client);
bool ok = connection.is_open();
- ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
if (!ok)
{
fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port();
return false;
}
- else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
+ ok = epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT());
+ if (!ok || res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
{
- fail_msg_writer() << fail_msg << " -- " << res.status;
+ fail_msg_writer() << fail_msg << " -- json_rpc_request: " << res.status;
return false;
}
else
@@ -123,15 +123,15 @@ namespace tools
t_http_connection connection(&m_http_client);
bool ok = connection.is_open();
- ok = ok && epee::net_utils::invoke_http_json(relative_url, req, res, m_http_client, t_http_connection::TIMEOUT());
if (!ok)
{
fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port();
return false;
}
- else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
+ ok = epee::net_utils::invoke_http_json(relative_url, req, res, m_http_client, t_http_connection::TIMEOUT());
+ if (!ok || res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ?
{
- fail_msg_writer() << fail_msg << " -- " << res.status;
+ fail_msg_writer() << fail_msg << "-- rpc_request: " << res.status;
return false;
}
else
diff --git a/src/common/scoped_message_writer.h b/src/common/scoped_message_writer.h
index 8fc98d2b0..d7517babb 100644
--- a/src/common/scoped_message_writer.h
+++ b/src/common/scoped_message_writer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/sfinae_helpers.h b/src/common/sfinae_helpers.h
index ddd456dd2..fa5052a2e 100644
--- a/src/common/sfinae_helpers.h
+++ b/src/common/sfinae_helpers.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016-2017, The Monero Project
+// Copyright (c) 2016-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/stack_trace.cpp b/src/common/stack_trace.cpp
index ed1093309..9c2bf4b53 100644
--- a/src/common/stack_trace.cpp
+++ b/src/common/stack_trace.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2016, The Monero Project
+// Copyright (c) 2016-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/stack_trace.h b/src/common/stack_trace.h
index 0f6bdc08b..272fb89ae 100644
--- a/src/common/stack_trace.h
+++ b/src/common/stack_trace.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2016, The Monero Project
+// Copyright (c) 2016-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp
index 5d749e08e..7fd16ceaf 100644
--- a/src/common/threadpool.cpp
+++ b/src/common/threadpool.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/threadpool.h b/src/common/threadpool.h
index 1d56d7605..a0e53b011 100644
--- a/src/common/threadpool.h
+++ b/src/common/threadpool.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/unordered_containers_boost_serialization.h b/src/common/unordered_containers_boost_serialization.h
index 4d82a1364..d78dc6a30 100644
--- a/src/common/unordered_containers_boost_serialization.h
+++ b/src/common/unordered_containers_boost_serialization.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/updates.cpp b/src/common/updates.cpp
index 2d9c2d89c..9eb402e0b 100644
--- a/src/common/updates.cpp
+++ b/src/common/updates.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/updates.h b/src/common/updates.h
index e494ed7ac..6ec22f183 100644
--- a/src/common/updates.h
+++ b/src/common/updates.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2017, The Monero Project
+// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/util.cpp b/src/common/util.cpp
index a4a435104..659ea31b8 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
@@ -34,6 +34,8 @@
#include <gnu/libc-version.h>
#endif
+#include "unbound.h"
+
#include "include_base_utils.h"
#include "file_io_utils.h"
#include "wipeable_string.h"
@@ -453,8 +455,7 @@ std::string get_nix_version_display_string()
// namespace fs = boost::filesystem;
// Windows < Vista: C:\Documents and Settings\Username\Application Data\CRYPTONOTE_NAME
// Windows >= Vista: C:\Users\Username\AppData\Roaming\CRYPTONOTE_NAME
- // Mac: ~/Library/Application Support/CRYPTONOTE_NAME
- // Unix: ~/.CRYPTONOTE_NAME
+ // Unix & Mac: ~/.CRYPTONOTE_NAME
std::string config_folder;
#ifdef WIN32
@@ -466,15 +467,8 @@ std::string get_nix_version_display_string()
pathRet = "/";
else
pathRet = pszHome;
-#ifdef MAC_OSX
- // Mac
- pathRet /= "Library/Application Support";
- config_folder = (pathRet + "/" + CRYPTONOTE_NAME);
-#else
- // Unix
config_folder = (pathRet + "/." + CRYPTONOTE_NAME);
#endif
-#endif
return config_folder;
}
@@ -522,6 +516,18 @@ std::string get_nix_version_display_string()
return std::error_code(code, std::system_category());
}
+ static bool unbound_built_with_threads()
+ {
+ ub_ctx *ctx = ub_ctx_create();
+ if (!ctx) return false; // cheat a bit, should not happen unless OOM
+ ub_ctx_zone_add(ctx, "monero", "unbound"); // this calls ub_ctx_finalize first, then errors out with UB_SYNTAX
+ // if no threads, bails out early with UB_NOERROR, otherwise fails with UB_AFTERFINAL id already finalized
+ bool with_threads = ub_ctx_async(ctx, 1) != 0; // UB_AFTERFINAL is not defined in public headers, check any error
+ ub_ctx_delete(ctx);
+ MINFO("libunbound was built " << (with_threads ? "with" : "without") << " threads");
+ return with_threads;
+ }
+
bool sanitize_locale()
{
// boost::filesystem throws for "invalid" locales, such as en_US.UTF-8, or kjsdkfs,
@@ -564,6 +570,9 @@ std::string get_nix_version_display_string()
OPENSSL_init_ssl(0, NULL);
#endif
+ if (!unbound_built_with_threads())
+ MCLOG_RED(el::Level::Warning, "global", "libunbound was not built with threads enabled - crashes may occur");
+
return true;
}
void set_strict_default_file_permissions(bool strict)
diff --git a/src/common/util.h b/src/common/util.h
index 53ff78af8..5afb42c97 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/common/varint.h b/src/common/varint.h
index cb785e61a..262bd1360 100644
--- a/src/common/varint.h
+++ b/src/common/varint.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//