summaryrefslogtreecommitdiffstats
path: root/Source/cmServer.cxx
diff options
context:
space:
mode:
authorJustin Berger <j.david.berger@gmail.com>2017-08-22 15:46:00 (GMT)
committerBrad King <brad.king@kitware.com>2017-08-31 19:35:46 (GMT)
commit693fa0a96e111270337eb76a4da1255774657e1a (patch)
tree84c1d74c18e4fae25c423ba391d2ec25b86aabc9 /Source/cmServer.cxx
parent882dcef8e02e432e6469b7fca38aff212d1541ab (diff)
downloadCMake-693fa0a96e111270337eb76a4da1255774657e1a.zip
CMake-693fa0a96e111270337eb76a4da1255774657e1a.tar.gz
CMake-693fa0a96e111270337eb76a4da1255774657e1a.tar.bz2
server: Added assert to monitor uv_run status
Diffstat (limited to 'Source/cmServer.cxx')
-rw-r--r--Source/cmServer.cxx12
1 files 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 <algorithm>
#include <cassert>
#include <cstdint>
+#include <iostream>
#include <memory>
#include <utility>
@@ -411,7 +412,10 @@ static void __start_thread(void* arg)
{
auto server = reinterpret_cast<cmServerBase*>(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;
}