From 693fa0a96e111270337eb76a4da1255774657e1a Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Tue, 22 Aug 2017 09:46:00 -0600 Subject: server: Added assert to monitor uv_run status --- Source/cmServer.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index c7f8704..b1b4020 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -411,7 +412,10 @@ static void __start_thread(void* arg) { auto server = reinterpret_cast(arg); std::string error; - server->Serve(&error); + bool success = server->Serve(&error); + if (!success || error.empty() == false) { + std::cerr << "Error during serve: " << error << std::endl; + } } static void __shutdownThread(uv_async_t* arg) @@ -457,8 +461,12 @@ bool cmServerBase::Serve(std::string* errorMessage) } if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) { + // It is important we don't ever let the event loop exit with open handles + // at best this is a memory leak, but it can also introduce race conditions + // which can hang the program. + assert(false && "Event loop stopped in unclean state."); + *errorMessage = "Internal Error: Event loop stopped in unclean state."; - StartShutDown(); return false; } -- cgit v0.12