Skip to content

Commit 73db063

Browse files
Use unique_ptr for upnp_thread (boost::thread)
1 parent 0024531 commit 73db063

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/net.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,22 +1534,20 @@ void ThreadMapPort()
15341534

15351535
void MapPort(bool fUseUPnP)
15361536
{
1537-
static boost::thread* upnp_thread = nullptr;
1537+
static std::unique_ptr<boost::thread> upnp_thread;
15381538

15391539
if (fUseUPnP)
15401540
{
15411541
if (upnp_thread) {
15421542
upnp_thread->interrupt();
15431543
upnp_thread->join();
1544-
delete upnp_thread;
15451544
}
1546-
upnp_thread = new boost::thread(boost::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort));
1545+
upnp_thread.reset(new boost::thread(boost::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort)));
15471546
}
15481547
else if (upnp_thread) {
15491548
upnp_thread->interrupt();
15501549
upnp_thread->join();
1551-
delete upnp_thread;
1552-
upnp_thread = nullptr;
1550+
upnp_thread.reset();
15531551
}
15541552
}
15551553

0 commit comments

Comments
 (0)