diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9158f088..859ac3df 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,3 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace -# - repo: https://github.com/pocc/pre-commit-hooks -# rev: master -# hooks: -# - id: clang-format diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8c066b5d..0df94b07 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All changes to this project will be documented in this file. +## [9.0.1] - 2020-03-24 + +(socket) selectInterrupt member is an unique_ptr instead of being a shared_ptr + ## [9.0.0] - 2020-03-23 (websocket) reset per-message deflate codec everytime we connect to a server/client diff --git a/ixwebsocket/IXSelectInterruptFactory.cpp b/ixwebsocket/IXSelectInterruptFactory.cpp index b0b51458..0cd4a278 100644 --- a/ixwebsocket/IXSelectInterruptFactory.cpp +++ b/ixwebsocket/IXSelectInterruptFactory.cpp @@ -14,12 +14,12 @@ namespace ix { - std::shared_ptr createSelectInterrupt() + SelectInterruptPtr createSelectInterrupt() { #if defined(__linux__) || defined(__APPLE__) - return std::make_shared(); + return std::make_unique(); #else - return std::make_shared(); + return std::make_unique(); #endif } } // namespace ix diff --git a/ixwebsocket/IXSelectInterruptFactory.h b/ixwebsocket/IXSelectInterruptFactory.h index f3e83b8f..5faf1d6e 100644 --- a/ixwebsocket/IXSelectInterruptFactory.h +++ b/ixwebsocket/IXSelectInterruptFactory.h @@ -11,5 +11,6 @@ namespace ix { class SelectInterrupt; - std::shared_ptr createSelectInterrupt(); + using SelectInterruptPtr = std::unique_ptr; + SelectInterruptPtr createSelectInterrupt(); } // namespace ix diff --git a/ixwebsocket/IXSocket.cpp b/ixwebsocket/IXSocket.cpp index f5cde89c..2c297df1 100644 --- a/ixwebsocket/IXSocket.cpp +++ b/ixwebsocket/IXSocket.cpp @@ -46,7 +46,7 @@ namespace ix PollResultType Socket::poll(bool readyToRead, int timeoutMs, int sockfd, - std::shared_ptr selectInterrupt) + const SelectInterruptPtr& selectInterrupt) { // // We used to use ::select to poll but on Android 9 we get large fds out of diff --git a/ixwebsocket/IXSocket.h b/ixwebsocket/IXSocket.h index 595d6398..84b0b737 100644 --- a/ixwebsocket/IXSocket.h +++ b/ixwebsocket/IXSocket.h @@ -38,6 +38,7 @@ typedef SSIZE_T ssize_t; namespace ix { class SelectInterrupt; + using SelectInterruptPtr = std::unique_ptr; enum class PollResultType { @@ -93,7 +94,7 @@ namespace ix static PollResultType poll(bool readyToRead, int timeoutMs, int sockfd, - std::shared_ptr selectInterrupt = nullptr); + const SelectInterruptPtr& selectInterrupt); // Used as special codes for pipe communication @@ -112,6 +113,6 @@ namespace ix std::vector _readBuffer; static constexpr size_t kChunkSize = 1 << 15; - std::shared_ptr _selectInterrupt; + SelectInterruptPtr _selectInterrupt; }; } // namespace ix diff --git a/ixwebsocket/IXSocketConnect.cpp b/ixwebsocket/IXSocketConnect.cpp index 1d887b7e..39a302be 100644 --- a/ixwebsocket/IXSocketConnect.cpp +++ b/ixwebsocket/IXSocketConnect.cpp @@ -9,6 +9,7 @@ #include "IXDNSLookup.h" #include "IXNetSystem.h" #include "IXSocket.h" +#include "IXSelectInterrupt.h" #include #include #include @@ -64,7 +65,8 @@ namespace ix int timeoutMs = 10; bool readyToRead = false; - PollResultType pollResult = Socket::poll(readyToRead, timeoutMs, fd); + auto selectInterrupt = std::make_unique(); + PollResultType pollResult = Socket::poll(readyToRead, timeoutMs, fd, selectInterrupt); if (pollResult == PollResultType::Timeout) { diff --git a/ixwebsocket/IXSocketServer.cpp b/ixwebsocket/IXSocketServer.cpp index 8eecab0f..776f3857 100644 --- a/ixwebsocket/IXSocketServer.cpp +++ b/ixwebsocket/IXSocketServer.cpp @@ -11,6 +11,7 @@ #include "IXSocket.h" #include "IXSocketConnect.h" #include "IXSocketFactory.h" +#include "IXSelectInterrupt.h" #include #include #include @@ -257,7 +258,8 @@ namespace ix // Use poll to check whether a new connection is in progress int timeoutMs = 10; bool readyToRead = true; - PollResultType pollResult = Socket::poll(readyToRead, timeoutMs, _serverFd); + auto selectInterrupt = std::make_unique(); + PollResultType pollResult = Socket::poll(readyToRead, timeoutMs, _serverFd, selectInterrupt); if (pollResult == PollResultType::Error) { diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 099b5051..b53a1269 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "9.0.0" +#define IX_WEBSOCKET_VERSION "9.0.1"