aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-27 21:08:03 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-27 21:08:03 +0100
commitf43d465da20864e9fc25fc3dd3f904c1a35bd8f9 (patch)
treed1faad281ce2191f699a09c6c936dafbd33b7737 /src/common
parentdns: make ctor private (diff)
downloadmonero-f43d465da20864e9fc25fc3dd3f904c1a35bd8f9.tar.xz
dns_utils: lock access to the singleton
This avoids races which could result in two objects being created
Diffstat (limited to 'src/common')
-rw-r--r--src/common/dns_utils.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index 8b7c9b4d9..ce57151f5 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -38,6 +38,8 @@
using namespace epee;
namespace bf = boost::filesystem;
+static std::mutex instance_lock;
+
namespace
{
@@ -326,6 +328,8 @@ std::string DNSResolver::get_dns_format_from_oa_address(const std::string& oa_ad
DNSResolver& DNSResolver::instance()
{
+ std::lock_guard<std::mutex> lock(instance_lock);
+
static DNSResolver* staticInstance = NULL;
if (staticInstance == NULL)
{