p2p: cleaner connection close()

(cherry picked from commit c5c9420d8cc9b5b44fd6dc177b3cac773e5e1674)
This commit is contained in:
j-berman
2026-10-04 18:50:19 -04:00
committed by such-gitea
parent bcf3973d3e
commit b56c56d807
@@ -1138,7 +1138,9 @@ namespace net_utils
bool connection<T>::close(const bool wait_for_shutdown) bool connection<T>::close(const bool wait_for_shutdown)
{ {
std::lock_guard<std::mutex> guard(m_state.lock); std::lock_guard<std::mutex> guard(m_state.lock);
if (m_state.status != status_t::RUNNING) if (m_state.status == status_t::TERMINATED || m_state.status == status_t::WASTED)
return true;
if (!wait_for_shutdown && m_state.status != status_t::RUNNING)
return false; return false;
terminate_async(); terminate_async();