mirror of
https://github.com/monero-project/monero.git
synced 2026-07-28 14:47:15 -07:00
Merge pull request #10905
d436311 epee: avoid bad_weak_ptr during connection teardown (selsta)
ACKs: vtnerd, SChernykh
This commit is contained in:
@@ -1224,16 +1224,13 @@ namespace net_utils
|
||||
template<typename T>
|
||||
bool connection<T>::add_ref()
|
||||
{
|
||||
try {
|
||||
auto self = connection<T>::shared_from_this();
|
||||
std::lock_guard<std::mutex> guard(m_state.lock);
|
||||
this->self = std::move(self);
|
||||
++m_state.protocol.reference_counter;
|
||||
return true;
|
||||
}
|
||||
catch (boost::bad_weak_ptr &exception) {
|
||||
auto self = connection<T>::weak_from_this().lock();
|
||||
if (!self)
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> guard(m_state.lock);
|
||||
this->self = std::move(self);
|
||||
++m_state.protocol.reference_counter;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
Reference in New Issue
Block a user