diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3d44eff..c2fd126 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update && \ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ apt-get install -y --no-install-recommends \ - git file jq libssl-dev \ + git file jq \ clang-21 libc++-21-dev libc++abi-21-dev lld-21 clang-tools-21 lldb-21 && \ rm -rf /var/lib/apt/lists/* diff --git a/.github/actions/setup-llvm/action.yml b/.github/actions/setup-llvm/action.yml index 56303cd..52d6546 100644 --- a/.github/actions/setup-llvm/action.yml +++ b/.github/actions/setup-llvm/action.yml @@ -4,7 +4,7 @@ inputs: packages: description: "Space-separated apt packages to install (default includes libc++, clang, lld, lldb, jq)" required: false - default: "libc++-21-dev libc++abi-21-dev clang-21 lld-21 lldb-21 jq libssl-dev clang-tools-21" + default: "libc++-21-dev libc++abi-21-dev clang-21 lld-21 lldb-21 jq clang-tools-21" runs: using: "composite" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39bbd75..a9f6a61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,7 +121,7 @@ jobs: - name: Setup LLVM + analysis tools uses: ./.github/actions/setup-llvm with: - packages: "libc++-21-dev libc++abi-21-dev clang-21 lld-21 lldb-21 jq clang-tools-21 clang-tidy-21 cppcheck libssl-dev" + packages: "libc++-21-dev libc++abi-21-dev clang-21 lld-21 lldb-21 jq clang-tools-21 clang-tidy-21 cppcheck" - name: Run clang-tidy (non-blocking) run: | diff --git a/README.md b/README.md index 3d27fd3..fcbac34 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This subproject is designed to work both: - **Standalone** (as its own repo, with `deps/tester` and `deps/cryptic` available), and - **As a dependency inside YarDB** (reusing YarDB’s `deps/tester` and `deps/cryptic`). -The WebSocket handshake hashes with [cryptic](https://github.com/ruoka/cryptic) [`v3.0.0`](https://github.com/ruoka/cryptic/releases/tag/v3.0.0), pinned at `deps/cryptic`. That module is not re-exported by `import net`. +The WebSocket handshake hashes with [cryptic](https://github.com/ruoka/cryptic) [`v3.0.2`](https://github.com/ruoka/cryptic/releases/tag/v3.0.2), pinned at `deps/cryptic`. That module is not re-exported by `import net`. ## Versioning & Releases diff --git a/deps/cryptic b/deps/cryptic index 57e6383..c3c7b84 160000 --- a/deps/cryptic +++ b/deps/cryptic @@ -1 +1 @@ -Subproject commit 57e6383c3896a26da14d39f35d56c28260f3958f +Subproject commit c3c7b84a83e74cf43a6b5afddfe7373e84e0dcb7 diff --git a/docs/release-policy.md b/docs/release-policy.md index 9d9a050..15552a0 100644 --- a/docs/release-policy.md +++ b/docs/release-policy.md @@ -32,7 +32,7 @@ modules-era cut. Prior tags `v1.0` / `v2.0` / `v2.1` are historical. Pin `v3.5.0` (or a later tag / deliberate commit). Nested `deps/tester` must match the parent tree’s tester pin — see [YarDB versioning](https://github.com/ruoka/YarDB/blob/master/docs/versioning.md). -`deps/cryptic` is pinned to cryptic [`v3.0.0`](https://github.com/ruoka/cryptic/releases/tag/v3.0.0) +`deps/cryptic` is pinned to cryptic [`v3.0.2`](https://github.com/ruoka/cryptic/releases/tag/v3.0.2) for the WebSocket handshake. `import net` does not re-export it. ## What is public diff --git a/net/net-endpoint_buf.c++m b/net/net-endpoint_buf.c++m index 7dcccc1..4961d98 100644 --- a/net/net-endpoint_buf.c++m +++ b/net/net-endpoint_buf.c++m @@ -15,8 +15,10 @@ public: explicit endpointbuf_base(socket&& s) noexcept : m_socket{std::move(s)} {} ~endpointbuf_base() override = default; + // Unread bytes in the get area count: the socket shows only what recv has + // not taken yet. bool wait_for(const std::chrono::milliseconds& timeout) const noexcept { - return m_socket.wait_for(timeout); + return gptr() < egptr() or m_socket.wait_for(timeout); } // Idle timeout for the next blocking recv. Zero (the default) blocks in diff --git a/net/net-endpoint_stream.test.c++ b/net/net-endpoint_stream.test.c++ index c4858e9..2a06241 100644 --- a/net/net-endpoint_stream.test.c++ +++ b/net/net-endpoint_stream.test.c++ @@ -165,6 +165,29 @@ tester::bdd::scenario("Bulk Data Transfer, [net]") = [] { check_eq(sent_data, received_data); }; + // Regression: wait_for polled only the socket, so a message that arrived in the + // same recv as the one before it sat in the get area until the peer sent more + // bytes (a FIX session read the second of two back-to-back reports one + // heartbeat late). + tester::bdd::scenario("wait_for sees a message already buffered, [net]") = [] { + using namespace std::chrono_literals; + using namespace std::string_literals; + + acceptor acc{"127.0.0.1", "0"}; + auto client = connect("127.0.0.1", std::to_string(acc.bound_port())); + auto [stream, peer_host, peer_port] = acc.accept(); + client << "first\nsecond\n" << net::flush; + + auto line = ""s; + require_true(stream.wait_for(2s)); + require_true(static_cast(std::getline(stream, line))); + check_eq(line, "first"s); + // The client sends nothing more: "second" came with "first". + check_true(stream.wait_for(200ms)); + require_true(static_cast(std::getline(stream, line))); + check_eq(line, "second"s); + }; + // Regression: after the TCP short-recv assemble fix, xsgetn looped recv for // every socket type when count >= N. udp_buffer_size == N, so the natural // max-datagram read waited forever for more bytes after the first message. diff --git a/net/net-websocket.c++m b/net/net-websocket.c++m index f0b89a3..205da7e 100644 --- a/net/net-websocket.c++m +++ b/net/net-websocket.c++m @@ -437,7 +437,7 @@ public: break; auto incoming = frame{}; const auto status = read_frame(m_stream, incoming, [&] { - // Prefer already-buffered bytes; wait_for only polls the socket. + // Bytes already buffered are read even once the deadline has passed. if(m_stream.rdbuf() != nullptr and m_stream.rdbuf()->in_avail() > 0) return true; const auto remaining = std::chrono::duration_cast(