diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-28 23:38:30 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-28 23:38:30 +0000 |
commit | 61ce8d6fde69795568804b619f086d1824406e92 (patch) | |
tree | 8ac556168b128f9f459a8b10c707dfafe11b0d9a | |
parent | wallet: do not return error if incoming_transfers finds none (diff) | |
download | monero-61ce8d6fde69795568804b619f086d1824406e92.tar.xz |
wallet_rpc_server: exit async, so we reply to stop_wallet RPC
Reported by saddam
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 11 | ||||
-rw-r--r-- | src/wallet/wallet_rpc_server.h | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index d2bbe8be4..0c1ea48c1 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -57,6 +57,7 @@ namespace tools //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::run() { + m_stop = false; m_net_server.add_idle_handler([this](){ try { m_wallet.refresh(); @@ -65,6 +66,14 @@ namespace tools } return true; }, 20000); + m_net_server.add_idle_handler([this](){ + if (m_stop.load(std::memory_order_relaxed)) + { + send_stop_signal(); + return false; + } + return true; + }, 500); //DO NOT START THIS SERVER IN MORE THEN 1 THREADS WITHOUT REFACTORING return epee::http_server_impl_base<wallet_rpc_server, connection_context>::run(1, true); @@ -648,8 +657,8 @@ namespace tools try { - send_stop_signal(); m_wallet.store(); + m_stop.store(true, std::memory_order_relaxed); } catch (std::exception& e) { diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index a7c5077e9..97b84fcb6 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -102,5 +102,6 @@ namespace tools wallet2& m_wallet; std::string m_port; std::string m_bind_ip; + std::atomic<bool> m_stop; }; } |