diff options
author | Lee Clagett <code@leeclagett.com> | 2021-01-21 15:14:36 -0500 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2021-01-19 04:44:03 +0000 |
commit | 545b9825d6997c617b4da1921cacb3662b729cb4 (patch) | |
tree | 7a6b61b95fd369da0edaf8415c58aca7324aacc7 | |
parent | Merge pull request #7286 (diff) | |
download | monero-545b9825d6997c617b4da1921cacb3662b729cb4.tar.xz |
Remove unnecessary atomic operations in levin code
-rw-r--r-- | contrib/epee/include/net/levin_protocol_handler_async.h | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index ddde701ee..5f2ee4719 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -146,7 +146,6 @@ public: stream_state_body }; - std::atomic<bool> m_deletion_initiated; std::atomic<bool> m_protocol_released; volatile uint32_t m_invoke_buf_ready; @@ -297,7 +296,6 @@ public: m_state(stream_state_head) { m_close_called = 0; - m_deletion_initiated = false; m_protocol_released = false; m_wait_count = 0; m_oponent_protocol_ver = 0; @@ -310,7 +308,6 @@ public: try { - m_deletion_initiated = true; if(m_connection_initialized) { m_config.del_connection(this); @@ -633,20 +630,8 @@ public: int err_code = LEVIN_OK; do { - if(m_deletion_initiated) - { - err_code = LEVIN_ERROR_CONNECTION_DESTROYED; - break; - } - CRITICAL_REGION_LOCAL(m_call_lock); - if(m_deletion_initiated) - { - err_code = LEVIN_ERROR_CONNECTION_DESTROYED; - break; - } - boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0); CRITICAL_REGION_BEGIN(m_invoke_response_handlers_lock); @@ -684,14 +669,8 @@ public: misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler( boost::bind(&async_protocol_handler::finish_outer_call, this)); - if(m_deletion_initiated) - return LEVIN_ERROR_CONNECTION_DESTROYED; - CRITICAL_REGION_LOCAL(m_call_lock); - if(m_deletion_initiated) - return LEVIN_ERROR_CONNECTION_DESTROYED; - boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0); if (command == m_connection_context.handshake_command()) @@ -706,7 +685,7 @@ public: uint64_t ticks_start = misc_utils::get_tick_count(); size_t prev_size = 0; - while(!boost::interprocess::ipcdetail::atomic_read32(&m_invoke_buf_ready) && !m_deletion_initiated && !m_protocol_released) + while(!boost::interprocess::ipcdetail::atomic_read32(&m_invoke_buf_ready) && !m_protocol_released) { if(m_cache_in_buffer.size() - prev_size >= MIN_BYTES_WANTED) { @@ -723,7 +702,7 @@ public: return LEVIN_ERROR_CONNECTION_DESTROYED; } - if(m_deletion_initiated || m_protocol_released) + if(m_protocol_released) return LEVIN_ERROR_CONNECTION_DESTROYED; CRITICAL_REGION_BEGIN(m_local_inv_buff_lock); @@ -739,14 +718,8 @@ public: misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler( boost::bind(&async_protocol_handler::finish_outer_call, this)); - if(m_deletion_initiated) - return LEVIN_ERROR_CONNECTION_DESTROYED; - CRITICAL_REGION_LOCAL(m_call_lock); - if(m_deletion_initiated) - return LEVIN_ERROR_CONNECTION_DESTROYED; - if (!send_message(command, in_buff, LEVIN_PACKET_REQUEST, false)) { LOG_ERROR_CC(m_connection_context, "Failed to send notify message"); @@ -768,9 +741,6 @@ public: boost::bind(&async_protocol_handler::finish_outer_call, this) ); - if(m_deletion_initiated) - return LEVIN_ERROR_CONNECTION_DESTROYED; - const std::size_t length = message.size(); if (!m_pservice_endpoint->do_send(std::move(message))) { |