From 8abf84d6e9a521fd672ce74df7cbbb5e7310694c Mon Sep 17 00:00:00 2001 From: Kaius Ruokonen Date: Sun, 25 Oct 2026 12:06:11 +0200 Subject: [PATCH 1/3] fix(endpointbuf): wait_for counts bytes already in the get area wait_for polled only the socket. When one recv brought two messages, the second sat in the get area and wait_for reported nothing readable until the peer sent more bytes: a FIX session read the second of two back-to-back execution reports only after the peer's next heartbeat. wait_for now returns true at once while unread bytes are buffered. The WebSocket close drain's comment no longer says wait_for polls only the socket. Co-authored-by: Cursor --- net/net-endpoint_buf.c++m | 4 +++- net/net-endpoint_stream.test.c++ | 23 +++++++++++++++++++++++ net/net-websocket.c++m | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) 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 a236834..d014777 100644 --- a/net/net-websocket.c++m +++ b/net/net-websocket.c++m @@ -532,7 +532,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( From 5b3547021b80c9fee4158a0127ffb756a2a3887f Mon Sep 17 00:00:00 2001 From: Kaius Ruokonen Date: Sun, 25 Oct 2026 18:51:49 +0200 Subject: [PATCH 2/3] chore(deps): bump cryptic to v3.0.2 The tests of cryptic's that net builds with its own used OpenSSL since v3.0.0, so the Linux test runner failed to link. v3.0.2 keeps OpenSSL inside cryptic's own build. Co-authored-by: Cursor --- README.md | 2 +- deps/cryptic | 2 +- docs/release-policy.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 From 2ead0f46b53aab97336559e202b24e6bc438f195 Mon Sep 17 00:00:00 2001 From: Kaius Ruokonen Date: Sun, 25 Oct 2026 18:51:49 +0200 Subject: [PATCH 3/3] ci: stop installing libssl-dev Nothing net builds uses OpenSSL. Co-authored-by: Cursor --- .devcontainer/Dockerfile | 2 +- .github/actions/setup-llvm/action.yml | 2 +- .github/workflows/ci.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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: |