diff options
author | Justin Berger <j.david.berger@gmail.com> | 2017-07-19 18:47:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-08-31 19:35:03 (GMT) |
commit | 546a58746967d10996075ca47a7198c1c375fdb2 (patch) | |
tree | 34c4e2f757e1cbeac3dc07c1dd5d06398821ba68 /Source/cmServer.cxx | |
parent | 9bad65940c87f594a5f1007019d4b187068dbce0 (diff) | |
download | CMake-546a58746967d10996075ca47a7198c1c375fdb2.zip CMake-546a58746967d10996075ca47a7198c1c375fdb2.tar.gz CMake-546a58746967d10996075ca47a7198c1c375fdb2.tar.bz2 |
server: Fixed mismatched new/delete; added proper shutdown procedure
Diffstat (limited to 'Source/cmServer.cxx')
-rw-r--r-- | Source/cmServer.cxx | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index c3e6811..f14e755 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -416,9 +416,18 @@ static void __start_thread(void* arg) server->Serve(&error); } +static void __shutdownThread(uv_async_t* arg) +{ + auto server = reinterpret_cast<cmServerBase*>(arg->data); + on_walk_to_shutdown(reinterpret_cast<uv_handle_t*>(arg), nullptr); + server->StartShutDown(); +} + bool cmServerBase::StartServeThread() { ServeThreadRunning = true; + uv_async_init(&Loop, &this->ShutdownSignal, __shutdownThread); + this->ShutdownSignal.data = this; uv_thread_create(&ServeThread, __start_thread, this); return true; } @@ -464,8 +473,6 @@ void cmServerBase::OnDisconnect() void cmServerBase::OnServeStart() { - uv_signal_start(&this->SIGINTHandler, &on_signal, SIGINT); - uv_signal_start(&this->SIGHUPHandler, &on_signal, SIGHUP); } void cmServerBase::StartShutDown() @@ -485,11 +492,7 @@ void cmServerBase::StartShutDown() } Connections.clear(); - uv_stop(&Loop); - uv_walk(&Loop, on_walk_to_shutdown, nullptr); - - uv_run(&Loop, UV_RUN_DEFAULT); } bool cmServerBase::OnSignal(int signum) @@ -503,12 +506,6 @@ cmServerBase::cmServerBase(cmConnection* connection) { uv_loop_init(&Loop); - uv_signal_init(&Loop, &this->SIGINTHandler); - uv_signal_init(&Loop, &this->SIGHUPHandler); - - this->SIGINTHandler.data = this; - this->SIGHUPHandler.data = this; - AddNewConnection(connection); } @@ -516,7 +513,7 @@ cmServerBase::~cmServerBase() { if (ServeThreadRunning) { - StartShutDown(); + uv_async_send(&this->ShutdownSignal); uv_thread_join(&ServeThread); } |