From 9112c43ebc96c8ea25042520f769cb1575439c22 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 18 Oct 2016 15:20:40 +0200 Subject: [PATCH] server-mode: Fix named pipe mode Do not treat a pointer itself as a `uv_stream_t`, but instead the pointed-to `uv_pipe_t`. It is unclear how this ever worked before in local testing. While at it, remove duplicate setup code and improve an error message. --- Source/cmServerConnection.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx index a814d16bb..b4af52b45 100644 --- a/Source/cmServerConnection.cxx +++ b/Source/cmServerConnection.cxx @@ -323,11 +323,10 @@ bool cmServerPipeConnection::DoSetup(std::string* errorMessage) ": " + uv_err_name(r); return false; } - auto serverStream = reinterpret_cast(&this->ServerPipe); - serverStream->data = this; + auto serverStream = reinterpret_cast(this->ServerPipe); if ((r = uv_listen(serverStream, 1, on_new_connection)) != 0) { - *errorMessage = std::string("Internal Error with ") + this->PipeName + - ": " + uv_err_name(r); + *errorMessage = std::string("Internal Error listening on ") + + this->PipeName + ": " + uv_err_name(r); return false; } @@ -340,7 +339,7 @@ void cmServerPipeConnection::TearDown() uv_close(reinterpret_cast(this->ClientPipe), &on_pipe_close); this->WriteStream->data = nullptr; } - uv_close(reinterpret_cast(&this->ServerPipe), &on_pipe_close); + uv_close(reinterpret_cast(this->ServerPipe), &on_pipe_close); this->ClientPipe = nullptr; this->ServerPipe = nullptr; @@ -364,7 +363,7 @@ void cmServerPipeConnection::Connect(uv_stream_t* server) this->ClientPipe = new uv_pipe_t; uv_pipe_init(this->Loop(), this->ClientPipe, 0); this->ClientPipe->data = this; - auto client = reinterpret_cast(&this->ClientPipe); + auto client = reinterpret_cast(this->ClientPipe); if (uv_accept(server, client) != 0) { uv_close(reinterpret_cast(client), nullptr); return;