mirror of
https://github.com/monero-project/monero.git
synced 2026-07-30 23:50:24 -07:00
p2p: wait_for on shutdown instead of indefinite wait
This commit is contained in:
@@ -1153,17 +1153,21 @@ namespace net_utils
|
|||||||
// execute terminate inside m_strand. So we wait for the connection's shutdown sequence to complete before stopping
|
// execute terminate inside m_strand. So we wait for the connection's shutdown sequence to complete before stopping
|
||||||
// the io_context.
|
// the io_context.
|
||||||
MDEBUG("Waiting for connection " << m_conn_context.m_connection_id << " to shutdown, current state: " << m_state.status);
|
MDEBUG("Waiting for connection " << m_conn_context.m_connection_id << " to shutdown, current state: " << m_state.status);
|
||||||
m_state.condition.wait(
|
const bool shutdown = m_state.condition.wait_for(
|
||||||
m_state.lock,
|
m_state.lock,
|
||||||
|
std::chrono::seconds(5),
|
||||||
[this]{
|
[this]{
|
||||||
return (
|
return (
|
||||||
m_state.status == status_t::TERMINATED || m_state.status == status_t::WASTED
|
m_state.status == status_t::TERMINATED || m_state.status == status_t::WASTED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if (shutdown)
|
||||||
MDEBUG("Shut down connection " << m_conn_context.m_connection_id);
|
MDEBUG("Shut down connection " << m_conn_context.m_connection_id);
|
||||||
|
else
|
||||||
|
MERROR("Connection " << m_conn_context.m_connection_id << " did not shut down");
|
||||||
|
|
||||||
return true;
|
return shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|||||||
Reference in New Issue
Block a user