diff options
author | luigi1111 <luigi1111w@gmail.com> | 2021-10-25 18:59:18 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2021-10-25 18:59:18 -0500 |
commit | e7d571c526e87696e0d68c5de7d0d322fef3d7a7 (patch) | |
tree | 6deef325e7ff65c065fe3f9a371e730e4c5ffc14 /src | |
parent | Merge pull request #8002 (diff) | |
parent | download: fix leak (diff) | |
download | monero-e7d571c526e87696e0d68c5de7d0d322fef3d7a7.tar.xz |
Merge pull request #8003
75d05b9 download: fix leak (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/common/download.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/common/download.cpp b/src/common/download.cpp index 3dd9c3976..c3dfa43d5 100644 --- a/src/common/download.cpp +++ b/src/common/download.cpp @@ -53,7 +53,7 @@ namespace tools download_thread_control(const std::string &path, const std::string &uri, std::function<void(const std::string&, const std::string&, bool)> result_cb, std::function<bool(const std::string&, const std::string&, size_t, ssize_t)> progress_cb): path(path), uri(uri), result_cb(result_cb), progress_cb(progress_cb), stop(false), stopped(false), success(false) {} - ~download_thread_control() { if (thread.joinable()) thread.detach(); } + ~download_thread_control() { if (thread.joinable()) { thread.detach(); thread = {}; } } }; static void download_thread(download_async_handle control) @@ -293,9 +293,13 @@ namespace tools { boost::lock_guard<boost::mutex> lock(control->mutex); if (control->stopped) + { + control->thread = {}; return true; + } } control->thread.join(); + control->thread = {}; return true; } @@ -305,10 +309,14 @@ namespace tools { boost::lock_guard<boost::mutex> lock(control->mutex); if (control->stopped) + { + control->thread = {}; return true; + } control->stop = true; } control->thread.join(); + control->thread = {}; return true; } } |