mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
Merge pull request #2131
a04faf56
abstract_tcp_server2: guard against accessing lock on a destroyed object (moneromooo-monero)
This commit is contained in:
commit
f584a2de92
@ -209,14 +209,14 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
bool connection<t_protocol_handler>::add_ref()
|
bool connection<t_protocol_handler>::add_ref()
|
||||||
{
|
{
|
||||||
TRY_ENTRY();
|
TRY_ENTRY();
|
||||||
//_dbg3("[sock " << socket_.native_handle() << "] add_ref, m_peer_number=" << mI->m_peer_number);
|
|
||||||
CRITICAL_REGION_LOCAL(m_self_refs_lock);
|
|
||||||
//_dbg3("[sock " << socket_.native_handle() << "] add_ref 2, m_peer_number=" << mI->m_peer_number);
|
|
||||||
|
|
||||||
// Use safe_shared_from_this, because of this is public method and it can be called on the object being deleted
|
// Use safe_shared_from_this, because of this is public method and it can be called on the object being deleted
|
||||||
auto self = safe_shared_from_this();
|
auto self = safe_shared_from_this();
|
||||||
if(!self)
|
if(!self)
|
||||||
return false;
|
return false;
|
||||||
|
//_dbg3("[sock " << socket_.native_handle() << "] add_ref, m_peer_number=" << mI->m_peer_number);
|
||||||
|
CRITICAL_REGION_LOCAL(self->m_self_refs_lock);
|
||||||
|
//_dbg3("[sock " << socket_.native_handle() << "] add_ref 2, m_peer_number=" << mI->m_peer_number);
|
||||||
if(m_was_shutdown)
|
if(m_was_shutdown)
|
||||||
return false;
|
return false;
|
||||||
m_self_refs.push_back(self);
|
m_self_refs.push_back(self);
|
||||||
|
Loading…
Reference in New Issue
Block a user