mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 01:12:39 +00:00
levin: armour against some "should not happen" case
If adding a response handler after the protocol is released, they could never be cancelled again, and would end up keeping a ref that never goes away
This commit is contained in:
parent
d0d76f771a
commit
e48dcb7a01
1 changed files with 5 additions and 0 deletions
|
@ -272,6 +272,11 @@ public:
|
||||||
bool add_invoke_response_handler(const callback_t &cb, uint64_t timeout, async_protocol_handler& con, int command)
|
bool add_invoke_response_handler(const callback_t &cb, uint64_t timeout, async_protocol_handler& con, int command)
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_invoke_response_handlers_lock);
|
CRITICAL_REGION_LOCAL(m_invoke_response_handlers_lock);
|
||||||
|
if (m_protocol_released)
|
||||||
|
{
|
||||||
|
MERROR("Adding response handler to a released object");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
boost::shared_ptr<invoke_response_handler_base> handler(boost::make_shared<anvoke_handler<callback_t>>(cb, timeout, con, command));
|
boost::shared_ptr<invoke_response_handler_base> handler(boost::make_shared<anvoke_handler<callback_t>>(cb, timeout, con, command));
|
||||||
m_invoke_response_handlers.push_back(handler);
|
m_invoke_response_handlers.push_back(handler);
|
||||||
return handler->is_timer_started();
|
return handler->is_timer_started();
|
||||||
|
|
Loading…
Reference in a new issue