From 2c4c2b8469415451eabc66eb473ab2b50c3e9bd6 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Fri, 13 Jan 2023 18:25:04 +0100 Subject: [PATCH] Fixed a rare crash on exit --- src/json_rpc_request.cpp | 2 +- src/p2pool_api.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/json_rpc_request.cpp b/src/json_rpc_request.cpp index 085e769..64acd93 100644 --- a/src/json_rpc_request.cpp +++ b/src/json_rpc_request.cpp @@ -315,7 +315,7 @@ int CurlContext::on_timer(CURLM* /*multi*/, long timeout_ms) return 0; } - if (timeout_ms == 0) { + if ((timeout_ms == 0) && !uv_is_closing(reinterpret_cast(&m_async))) { // 0 ms timeout, but we can't just call on_timeout() here - we have to kick the UV loop const int result = uv_async_send(&m_async); if (result < 0) { diff --git a/src/p2pool_api.cpp b/src/p2pool_api.cpp index 27b61f8..6cf56c6 100644 --- a/src/p2pool_api.cpp +++ b/src/p2pool_api.cpp @@ -124,7 +124,9 @@ void p2pool_api::dump_to_file_async_internal(Category category, const char* file m_dumpData[path] = std::move(buf); } - uv_async_send(&m_dumpToFileAsync); + if (!uv_is_closing(reinterpret_cast(&m_dumpToFileAsync))) { + uv_async_send(&m_dumpToFileAsync); + } } void p2pool_api::dump_to_file()