diff --git a/CMakeLists.txt b/CMakeLists.txt index 23d1f561..856faf10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif() # Project configuration # -project(uvw VERSION 2.0.0) +project(uvw VERSION 2.1.0) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) diff --git a/cmake/in/deps.in b/cmake/in/deps.in index ba0e7e7f..fa16d93f 100644 --- a/cmake/in/deps.in +++ b/cmake/in/deps.in @@ -17,7 +17,7 @@ ExternalProject_Add( ExternalProject_Add( libuv GIT_REPOSITORY https://github.com/libuv/libuv.git - GIT_TAG v1.31.0 + GIT_TAG v1.32.0 SOURCE_DIR @LIBUV_DEPS_DIR@ CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/conanfile.py b/conanfile.py index 85a59735..078b1e96 100644 --- a/conanfile.py +++ b/conanfile.py @@ -14,7 +14,7 @@ class UVMConan(ConanFile): exports = "LICENSE" exports_sources = "src/*" no_copy_source = True - requires = "libuv/1.30.0@bincrafters/stable" + requires = "libuv/1.32.0@bincrafters/stable" def package(self): self.copy(pattern="LICENSE", dst="licenses") diff --git a/src/uvw/handle.hpp b/src/uvw/handle.hpp index f5322be0..782ff4eb 100644 --- a/src/uvw/handle.hpp +++ b/src/uvw/handle.hpp @@ -26,8 +26,8 @@ struct CloseEvent {}; * Base type for all `uvw` handle types. */ template -class Handle: public BaseHandle, public Resource -{ +class Handle: public BaseHandle, public Resource { +protected: static void closeCallback(uv_handle_t *handle) { Handle &ref = *(static_cast(handle->data)); auto ptr = ref.shared_from_this(); @@ -36,7 +36,6 @@ class Handle: public BaseHandle, public Resource ref.publish(CloseEvent{}); } -protected: static void allocCallback(uv_handle_t *, std::size_t suggested, uv_buf_t *buf) { auto size = static_cast(suggested); *buf = uv_buf_init(new char[size], size); diff --git a/src/uvw/tcp.hpp b/src/uvw/tcp.hpp index af5a81d8..512889a5 100644 --- a/src/uvw/tcp.hpp +++ b/src/uvw/tcp.hpp @@ -251,6 +251,21 @@ public: connect(std::move(addr.ip), addr.port); } + /** + * @brief Resets a TCP connection by sending a RST packet. + * + * This is accomplished by setting the `SO_LINGER` socket option with a + * linger interval of zero and then calling `close`.
+ * Due to some platform inconsistencies, mixing of `shutdown` and + * `closeReset` calls is not allowed. + * + * A CloseEvent event is emitted when the connection has been reset.
+ * An ErrorEvent event is emitted in case of errors. + */ + void closeReset() { + invoke(&uv_tcp_close_reset, get(), &this->closeCallback); + } + private: enum { DEFAULT, FLAGS } tag; unsigned int flags;