diff options
author | Alexander Blair <snipa@jagtech.io> | 2020-01-16 17:32:15 -0800 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2020-01-16 17:32:15 -0800 |
commit | fbc15de2cd57353bb6cf74b076d02d463c7aa3fa (patch) | |
tree | 5f512c2642c76c89bab8345ba39b37e84332aa1d /contrib | |
parent | Merge pull request #6124 (diff) | |
parent | epee: fix console_handlers_binder race, wait for thread to finish (diff) | |
download | monero-fbc15de2cd57353bb6cf74b076d02d463c7aa3fa.tar.xz |
Merge pull request #6125
584d057f epee: fix console_handlers_binder race, wait for thread to finish (xiphon)
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/epee/include/console_handler.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h index 13747b0c8..1b716fca4 100644 --- a/contrib/epee/include/console_handler.h +++ b/contrib/epee/include/console_handler.h @@ -605,10 +605,17 @@ eof: std::unique_ptr<boost::thread> m_console_thread; async_console_handler m_console_handler; public: + ~console_handlers_binder() { + stop_handling(); + if (m_console_thread.get() != nullptr) + { + m_console_thread->join(); + } + } + bool start_handling(std::function<std::string(void)> prompt, const std::string& usage_string = "", std::function<void(void)> exit_handler = NULL) { m_console_thread.reset(new boost::thread(boost::bind(&console_handlers_binder::run_handling, this, prompt, usage_string, exit_handler))); - m_console_thread->detach(); return true; } bool start_handling(const std::string &prompt, const std::string& usage_string = "", std::function<void(void)> exit_handler = NULL) |