From 73db0635a38744b09058b590ac246af5499630c9 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 9 Aug 2017 16:00:44 +0200 Subject: [PATCH] Use unique_ptr for upnp_thread (boost::thread) --- src/net.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index d5bd4c162b71e..2db1f2a04f496 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1534,22 +1534,20 @@ void ThreadMapPort() void MapPort(bool fUseUPnP) { - static boost::thread* upnp_thread = nullptr; + static std::unique_ptr upnp_thread; if (fUseUPnP) { if (upnp_thread) { upnp_thread->interrupt(); upnp_thread->join(); - delete upnp_thread; } - upnp_thread = new boost::thread(boost::bind(&TraceThread, "upnp", &ThreadMapPort)); + upnp_thread.reset(new boost::thread(boost::bind(&TraceThread, "upnp", &ThreadMapPort))); } else if (upnp_thread) { upnp_thread->interrupt(); upnp_thread->join(); - delete upnp_thread; - upnp_thread = nullptr; + upnp_thread.reset(); } }