From fa83b39ff3ae3fbad93df002915c0e5f99c104a9 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 18 May 2020 09:06:55 -0400 Subject: init: Remove confusing and redundant InitError The "A fatal internal error occurred, see debug.log for details" is redundant because init.cpp will already show an InitError with a better error message as well as the hint to check the debug.log --- src/httprpc.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 3c3e6e5bba..f17101ef56 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -251,9 +250,6 @@ static bool InitRPCAuthentication() { LogPrintf("No rpcpassword set - using random cookie authentication.\n"); if (!GenerateAuthCookie(&strRPCUserColonPass)) { - uiInterface.ThreadSafeMessageBox( - _("Error: A fatal internal error occurred, see debug.log for details"), // Same message as AbortNode - "", CClientUIInterface::MSG_ERROR); return false; } } else { -- cgit v1.2.3 From faf45d1f1f997c316fc4c611a23c4456533eefe9 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 18 May 2020 09:17:28 -0400 Subject: http: Avoid crash when g_thread_http was never started g_thread_http can not be joined when it is not joinable. Avoid crashing the node by adding the required check and add a test. --- src/httpserver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/httpserver.cpp b/src/httpserver.cpp index ffe246b241..5e78fd1d71 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -421,7 +421,7 @@ bool UpdateHTTPServerLogging(bool enable) { #endif } -static std::thread threadHTTP; +static std::thread g_thread_http; static std::vector g_thread_http_workers; void StartHTTPServer() @@ -429,7 +429,7 @@ void StartHTTPServer() LogPrint(BCLog::HTTP, "Starting HTTP server\n"); int rpcThreads = std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); LogPrintf("HTTP: starting %d worker threads\n", rpcThreads); - threadHTTP = std::thread(ThreadHTTP, eventBase); + g_thread_http = std::thread(ThreadHTTP, eventBase); for (int i = 0; i < rpcThreads; i++) { g_thread_http_workers.emplace_back(HTTPWorkQueueRun, workQueue, i); @@ -467,7 +467,7 @@ void StopHTTPServer() boundSockets.clear(); if (eventBase) { LogPrint(BCLog::HTTP, "Waiting for HTTP event thread to exit\n"); - threadHTTP.join(); + if (g_thread_http.joinable()) g_thread_http.join(); } if (eventHTTP) { evhttp_free(eventHTTP); -- cgit v1.2.3