mirror of
https://github.com/monero-project/monero.git
synced 2024-12-13 20:06:32 +02:00
dns_utils: lock access to the singleton
This avoids races which could result in two objects being created
This commit is contained in:
parent
5990344cb0
commit
f43d465da2
@ -38,6 +38,8 @@
|
|||||||
using namespace epee;
|
using namespace epee;
|
||||||
namespace bf = boost::filesystem;
|
namespace bf = boost::filesystem;
|
||||||
|
|
||||||
|
static std::mutex instance_lock;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -326,6 +328,8 @@ std::string DNSResolver::get_dns_format_from_oa_address(const std::string& oa_ad
|
|||||||
|
|
||||||
DNSResolver& DNSResolver::instance()
|
DNSResolver& DNSResolver::instance()
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(instance_lock);
|
||||||
|
|
||||||
static DNSResolver* staticInstance = NULL;
|
static DNSResolver* staticInstance = NULL;
|
||||||
if (staticInstance == NULL)
|
if (staticInstance == NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user