mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
mapport: remove unnecessary 'g_mapport_enabled'
It was only necessary for switching between mapping protocols. It's also used to return in ThreadMapPort but we can just use the interrupt for this purpose.
This commit is contained in:
parent
8fb45fcda0
commit
9e6cba2988
1 changed files with 3 additions and 17 deletions
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
static CThreadInterrupt g_mapport_interrupt;
|
static CThreadInterrupt g_mapport_interrupt;
|
||||||
static std::thread g_mapport_thread;
|
static std::thread g_mapport_thread;
|
||||||
static std::atomic_bool g_mapport_enabled{false};
|
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
static constexpr auto PORT_MAPPING_REANNOUNCE_PERIOD{20min};
|
static constexpr auto PORT_MAPPING_REANNOUNCE_PERIOD{20min};
|
||||||
|
@ -124,20 +123,9 @@ static bool ProcessPCP()
|
||||||
|
|
||||||
static void ThreadMapPort()
|
static void ThreadMapPort()
|
||||||
{
|
{
|
||||||
bool ok;
|
|
||||||
do {
|
do {
|
||||||
ok = false;
|
ProcessPCP();
|
||||||
|
} while (g_mapport_interrupt.sleep_for(PORT_MAPPING_RETRY_PERIOD));
|
||||||
if (g_mapport_enabled) {
|
|
||||||
ok = ProcessPCP();
|
|
||||||
if (ok) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_mapport_enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (ok || g_mapport_interrupt.sleep_for(PORT_MAPPING_RETRY_PERIOD));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartThreadMapPort()
|
void StartThreadMapPort()
|
||||||
|
@ -150,8 +138,7 @@ void StartThreadMapPort()
|
||||||
|
|
||||||
void StartMapPort(bool enable)
|
void StartMapPort(bool enable)
|
||||||
{
|
{
|
||||||
g_mapport_enabled = enable;
|
if (enable) {
|
||||||
if (g_mapport_enabled) {
|
|
||||||
StartThreadMapPort();
|
StartThreadMapPort();
|
||||||
} else {
|
} else {
|
||||||
InterruptMapPort();
|
InterruptMapPort();
|
||||||
|
@ -161,7 +148,6 @@ void StartMapPort(bool enable)
|
||||||
|
|
||||||
void InterruptMapPort()
|
void InterruptMapPort()
|
||||||
{
|
{
|
||||||
g_mapport_enabled = false;
|
|
||||||
if (g_mapport_thread.joinable()) {
|
if (g_mapport_thread.joinable()) {
|
||||||
g_mapport_interrupt();
|
g_mapport_interrupt();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue