mirror of
https://github.com/monero-project/monero.git
synced 2026-07-30 23:50:24 -07:00
connection: try-catch handles
This commit is contained in:
@@ -172,6 +172,17 @@ namespace debug
|
|||||||
return return_val; \
|
return return_val; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CATCH_ENTRY_SWALLOW_EX(location) } \
|
||||||
|
catch(const std::exception& ex) \
|
||||||
|
{ \
|
||||||
|
(void)(ex); \
|
||||||
|
LOG_ERROR("Exception at [" << location << "], what=" << ex.what()); \
|
||||||
|
}\
|
||||||
|
catch(...)\
|
||||||
|
{\
|
||||||
|
LOG_ERROR("Exception at [" << location << "], generic exception \"...\"");\
|
||||||
|
}
|
||||||
|
|
||||||
#define CATCH_ENTRY_L0(lacation, return_val) CATCH_ENTRY(lacation, return_val)
|
#define CATCH_ENTRY_L0(lacation, return_val) CATCH_ENTRY(lacation, return_val)
|
||||||
#define CATCH_ENTRY_L1(lacation, return_val) CATCH_ENTRY(lacation, return_val)
|
#define CATCH_ENTRY_L1(lacation, return_val) CATCH_ENTRY(lacation, return_val)
|
||||||
#define CATCH_ENTRY_L2(lacation, return_val) CATCH_ENTRY(lacation, return_val)
|
#define CATCH_ENTRY_L2(lacation, return_val) CATCH_ENTRY(lacation, return_val)
|
||||||
|
|||||||
@@ -423,10 +423,13 @@ namespace net_utils
|
|||||||
boost::asio::post(
|
boost::asio::post(
|
||||||
connection_basic::strand_,
|
connection_basic::strand_,
|
||||||
[this, self, bytes_transferred]{
|
[this, self, bytes_transferred]{
|
||||||
bool success = m_handler.handle_recv(
|
bool success = false;
|
||||||
|
TRY_ENTRY();
|
||||||
|
success = m_handler.handle_recv(
|
||||||
reinterpret_cast<char *>(m_state.data.read.buffer.data()),
|
reinterpret_cast<char *>(m_state.data.read.buffer.data()),
|
||||||
bytes_transferred
|
bytes_transferred
|
||||||
);
|
);
|
||||||
|
CATCH_ENTRY_SWALLOW_EX("m_handler.handle_recv");
|
||||||
std::lock_guard<std::mutex> guard(m_state.lock);
|
std::lock_guard<std::mutex> guard(m_state.lock);
|
||||||
const bool error_status = m_state.status == status_t::INTERRUPTED
|
const bool error_status = m_state.status == status_t::INTERRUPTED
|
||||||
|| m_state.status == status_t::TERMINATING
|
|| m_state.status == status_t::TERMINATING
|
||||||
@@ -1186,7 +1189,9 @@ namespace net_utils
|
|||||||
auto self = connection<T>::shared_from_this();
|
auto self = connection<T>::shared_from_this();
|
||||||
++m_state.protocol.wait_callback;
|
++m_state.protocol.wait_callback;
|
||||||
boost::asio::post(connection_basic::strand_, [this, self]{
|
boost::asio::post(connection_basic::strand_, [this, self]{
|
||||||
|
TRY_ENTRY();
|
||||||
m_handler.handle_qued_callback();
|
m_handler.handle_qued_callback();
|
||||||
|
CATCH_ENTRY_SWALLOW_EX("m_handler.handle_qued_callback");
|
||||||
std::lock_guard<std::mutex> guard(m_state.lock);
|
std::lock_guard<std::mutex> guard(m_state.lock);
|
||||||
--m_state.protocol.wait_callback;
|
--m_state.protocol.wait_callback;
|
||||||
if (m_state.status == status_t::INTERRUPTED)
|
if (m_state.status == status_t::INTERRUPTED)
|
||||||
|
|||||||
@@ -338,10 +338,10 @@ std::pair<uint64_t, uint64_t> block_queue::get_next_span_if_scheduled(std::vecto
|
|||||||
void block_queue::reset_next_span_time(boost::posix_time::ptime t)
|
void block_queue::reset_next_span_time(boost::posix_time::ptime t)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||||
CHECK_AND_ASSERT_THROW_MES(!blocks.empty(), "No next span to reset time");
|
CHECK_AND_ASSERT_MES_NO_RET(!blocks.empty(), "No next span to reset time");
|
||||||
block_map::iterator i = blocks.begin();
|
block_map::iterator i = blocks.begin();
|
||||||
CHECK_AND_ASSERT_THROW_MES(i != blocks.end(), "No next span to reset time");
|
CHECK_AND_ASSERT_MES_NO_RET(i != blocks.end(), "No next span to reset time");
|
||||||
CHECK_AND_ASSERT_THROW_MES(i->blocks.empty(), "Next span is not empty");
|
CHECK_AND_ASSERT_MES_NO_RET(i->blocks.empty(), "Next span is not empty");
|
||||||
(boost::posix_time::ptime&)i->time = t; // sod off, time doesn't influence sorting
|
(boost::posix_time::ptime&)i->time = t; // sod off, time doesn't influence sorting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user