mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Use unique_ptr for upnp_thread (boost::thread)
This commit is contained in:
parent
0024531625
commit
73db0635a3
1 changed files with 3 additions and 5 deletions
|
|
@ -1534,22 +1534,20 @@ void ThreadMapPort()
|
||||||
|
|
||||||
void MapPort(bool fUseUPnP)
|
void MapPort(bool fUseUPnP)
|
||||||
{
|
{
|
||||||
static boost::thread* upnp_thread = nullptr;
|
static std::unique_ptr<boost::thread> upnp_thread;
|
||||||
|
|
||||||
if (fUseUPnP)
|
if (fUseUPnP)
|
||||||
{
|
{
|
||||||
if (upnp_thread) {
|
if (upnp_thread) {
|
||||||
upnp_thread->interrupt();
|
upnp_thread->interrupt();
|
||||||
upnp_thread->join();
|
upnp_thread->join();
|
||||||
delete upnp_thread;
|
|
||||||
}
|
}
|
||||||
upnp_thread = new boost::thread(boost::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort));
|
upnp_thread.reset(new boost::thread(boost::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort)));
|
||||||
}
|
}
|
||||||
else if (upnp_thread) {
|
else if (upnp_thread) {
|
||||||
upnp_thread->interrupt();
|
upnp_thread->interrupt();
|
||||||
upnp_thread->join();
|
upnp_thread->join();
|
||||||
delete upnp_thread;
|
upnp_thread.reset();
|
||||||
upnp_thread = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue