From f43d465da20864e9fc25fc3dd3f904c1a35bd8f9 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 27 Aug 2015 21:08:03 +0100 Subject: dns_utils: lock access to the singleton This avoids races which could result in two objects being created --- src/common/dns_utils.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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 lock(instance_lock); + static DNSResolver* staticInstance = NULL; if (staticInstance == NULL) { -- cgit v1.2.3