diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-08-27 21:08:03 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-08-27 21:08:03 +0100 |
commit | f43d465da20864e9fc25fc3dd3f904c1a35bd8f9 (patch) | |
tree | d1faad281ce2191f699a09c6c936dafbd33b7737 /src | |
parent | dns: make ctor private (diff) | |
download | monero-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')
-rw-r--r-- | src/common/dns_utils.cpp | 4 |
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) { |