diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2017-08-09 16:00:44 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2017-11-09 16:52:44 +0100 |
commit | 73db0635a38744b09058b590ac246af5499630c9 (patch) | |
tree | 236cdac11035e74681fe8143fcf4f243764f567c | |
parent | 0024531625dac862626a3adfe5e8b6e5d8498e0b (diff) |
Use unique_ptr for upnp_thread (boost::thread)
-rw-r--r-- | src/net.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/net.cpp b/src/net.cpp index d5bd4c162b..2db1f2a04f 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<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(); } } |