Skip to content

Commit

Permalink
Use unique_ptr for upnp_thread (boost::thread)
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed Nov 9, 2017
1 parent 0024531 commit 73db063
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/net.cpp
Expand Up @@ -1534,22 +1534,20 @@ void ThreadMapPort()

void MapPort(bool fUseUPnP)
{
static boost::thread* upnp_thread = nullptr;
static std::unique_ptr<boost::thread> upnp_thread;

if (fUseUPnP)
{
if (upnp_thread) {
upnp_thread->interrupt();
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) {
upnp_thread->interrupt();
upnp_thread->join();
delete upnp_thread;
upnp_thread = nullptr;
upnp_thread.reset();
}
}

Expand Down

0 comments on commit 73db063

Please sign in to comment.