diff options
author | Brad King <brad.king@kitware.com> | 2017-11-30 15:57:43 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-11-30 15:57:52 (GMT) |
commit | 92b212e87542552a8dd095608098609a3ebe1d6d (patch) | |
tree | 16787e74a21534590493b7237271aeba2443b27d /Source/cmConnection.cxx | |
parent | c2ea729c87cee2fb19d34090ef00e42d12fb59f2 (diff) | |
parent | 1e9b7d3ceb882d3feb59324b6e55d40cc795576b (diff) | |
download | CMake-92b212e87542552a8dd095608098609a3ebe1d6d.zip CMake-92b212e87542552a8dd095608098609a3ebe1d6d.tar.gz CMake-92b212e87542552a8dd095608098609a3ebe1d6d.tar.bz2 |
Merge topic 'libuv-raii'
1e9b7d3c server: Switched to a auto model for handles
f43b9219 tests: Added tests to verify UV RAII semantics/constructs
a3abb85c Add RAII handles for libuv handle types
90f8db26 tests: unconditionally enabled server tests
b56b51fc utility: Disabled copy ctors in thread classes
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1453
Diffstat (limited to 'Source/cmConnection.cxx')
-rw-r--r-- | Source/cmConnection.cxx | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx index 28ba12c..50e1936 100644 --- a/Source/cmConnection.cxx +++ b/Source/cmConnection.cxx @@ -26,7 +26,7 @@ void cmEventBasedConnection::on_alloc_buffer(uv_handle_t* handle, void cmEventBasedConnection::on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - auto conn = reinterpret_cast<cmEventBasedConnection*>(stream->data); + auto conn = static_cast<cmEventBasedConnection*>(stream->data); if (conn) { if (nread >= 0) { conn->ReadData(std::string(buf->base, buf->base + nread)); @@ -55,7 +55,7 @@ void cmEventBasedConnection::on_write(uv_write_t* req, int status) void cmEventBasedConnection::on_new_connection(uv_stream_t* stream, int status) { (void)(status); - auto conn = reinterpret_cast<cmEventBasedConnection*>(stream->data); + auto conn = static_cast<cmEventBasedConnection*>(stream->data); if (conn) { conn->Connect(stream); @@ -76,7 +76,7 @@ void cmEventBasedConnection::WriteData(const std::string& _data) #endif auto data = _data; - assert(this->WriteStream); + assert(this->WriteStream.get()); if (BufferStrategy) { data = BufferStrategy->BufferOutMessage(data); } @@ -87,8 +87,7 @@ void cmEventBasedConnection::WriteData(const std::string& _data) req->req.data = this; req->buf = uv_buf_init(new char[ds], static_cast<unsigned int>(ds)); memcpy(req->buf.base, data.c_str(), ds); - uv_write(reinterpret_cast<uv_write_t*>(req), - static_cast<uv_stream_t*>(this->WriteStream), &req->buf, 1, + uv_write(reinterpret_cast<uv_write_t*>(req), this->WriteStream, &req->buf, 1, on_write); } @@ -156,13 +155,11 @@ bool cmConnection::OnServeStart(std::string* errString) bool cmEventBasedConnection::OnConnectionShuttingDown() { - if (this->WriteStream) { + if (this->WriteStream.get()) { this->WriteStream->data = nullptr; } - if (this->ReadStream) { - this->ReadStream->data = nullptr; - } - this->ReadStream = nullptr; - this->WriteStream = nullptr; + + WriteStream.reset(); + return true; } |