Skip to content

Commit 28e2961

Browse files
committed
refactor: Replace magic number with named constant
1 parent 02ccf69 commit 28e2961

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mapport.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ static_assert(MINIUPNPC_API_VERSION >= 10, "miniUPnPc API version >= 10 assumed"
3434
#ifdef USE_UPNP
3535
static CThreadInterrupt g_upnp_interrupt;
3636
static std::thread g_upnp_thread;
37+
38+
using namespace std::chrono_literals;
39+
static constexpr auto PORT_MAPPING_REANNOUNCE_PERIOD{20min};
40+
3741
static void ThreadMapPort()
3842
{
3943
std::string port = strprintf("%u", GetListenPort());
@@ -84,7 +88,7 @@ static void ThreadMapPort()
8488
} else {
8589
LogPrintf("UPnP Port Mapping successful.\n");
8690
}
87-
} while (g_upnp_interrupt.sleep_for(std::chrono::minutes(20)));
91+
} while (g_upnp_interrupt.sleep_for(PORT_MAPPING_REANNOUNCE_PERIOD));
8892

8993
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
9094
LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r);

0 commit comments

Comments
 (0)