mirror of
https://github.com/monero-project/monero.git
synced 2026-06-12 19:11:36 -07:00
p2p: make stop signal idempotent
This commit is contained in:
@@ -1581,7 +1581,11 @@ namespace net_utils
|
||||
template<class t_protocol_handler>
|
||||
void boosted_tcp_server<t_protocol_handler>::send_stop_signal(std::function<void()> close_all_connections)
|
||||
{
|
||||
m_stop_signal_sent = true;
|
||||
if (m_stop_signal_sent.exchange(true))
|
||||
{
|
||||
MDEBUG("Stop signal already sent");
|
||||
return;
|
||||
}
|
||||
typename connection<t_protocol_handler>::shared_state *state = static_cast<typename connection<t_protocol_handler>::shared_state*>(m_state.get());
|
||||
state->stop_signal_sent = true;
|
||||
TRY_ENTRY();
|
||||
|
||||
@@ -449,6 +449,7 @@ namespace nodetool
|
||||
bool m_use_ipv6;
|
||||
bool m_require_ipv4;
|
||||
std::atomic<bool> is_closing;
|
||||
std::atomic<bool> m_stop_signal_sent_once{false};
|
||||
std::unique_ptr<boost::thread> mPeersLoggerThread;
|
||||
//critical_section m_connections_lock;
|
||||
//connections_indexed_container m_connections;
|
||||
|
||||
@@ -1107,6 +1107,11 @@ namespace nodetool
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::send_stop_signal()
|
||||
{
|
||||
if (m_stop_signal_sent_once.exchange(true))
|
||||
{
|
||||
MDEBUG("[node] Stop signal already sent");
|
||||
return true;
|
||||
}
|
||||
MDEBUG("[node] stopping server payload handler");
|
||||
m_payload_handler.stop();
|
||||
MDEBUG("[node] sending stop signal");
|
||||
|
||||
Reference in New Issue
Block a user