dns_utils: lock access to the singleton

This avoids races which could result in two objects being created
This commit is contained in:
moneromooo-monero 2015-08-27 21:08:03 +01:00
parent 5990344cb0
commit f43d465da2
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 4 additions and 0 deletions

View File

@ -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)
{