Fixed DnsUvBackend storage cleanup.

This commit is contained in:
XMRig 2023-02-09 21:45:50 +07:00
parent 81e87a6931
commit 667f636c62
No known key found for this signature in database
GPG key ID: 446A53638BE94409
2 changed files with 24 additions and 14 deletions

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,18 +28,19 @@
namespace xmrig {
static Storage<DnsUvBackend>* storage = nullptr;
Storage<DnsUvBackend>& DnsUvBackend::getStorage()
static Storage<DnsUvBackend> *storage = nullptr;
Storage<DnsUvBackend> &DnsUvBackend::getStorage()
{
if (storage == nullptr) storage = new Storage<DnsUvBackend>();
if (storage == nullptr) {
storage = new Storage<DnsUvBackend>();
}
return *storage;
}
void DnsUvBackend::releaseStorage()
{
delete storage;
}
static addrinfo hints{};
@ -61,8 +62,14 @@ xmrig::DnsUvBackend::DnsUvBackend()
xmrig::DnsUvBackend::~DnsUvBackend()
{
getStorage().release(m_key);
releaseStorage();
assert(storage);
storage->release(m_key);
if (storage->isEmpty()) {
delete storage;
storage = nullptr;
}
}