diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7f9fd5..b7926953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 255: + +* Add idle ping suspend test + +-------------------------------------------------------------------------------- + Version 254: * Fix data race in test::stream::connect diff --git a/test/beast/websocket/ping.cpp b/test/beast/websocket/ping.cpp index 7f63934f..1810927b 100644 --- a/test/beast/websocket/ping.cpp +++ b/test/beast/websocket/ping.cpp @@ -10,8 +10,11 @@ // Test that header file is self-contained. #include +#include + #include "test.hpp" +#include #include #include @@ -366,6 +369,46 @@ public: BEAST_EXPECT(count == 3); }); + // suspend idle ping + { + using socket_type = + net::basic_stream_socket< + net::ip::tcp, + net::executor>; + net::io_context ioc; + stream ws1(ioc); + stream ws2(ioc); + ws1.set_option(stream_base::timeout{ + stream_base::none(), + std::chrono::seconds(0), + true}); + test::connect( + ws1.next_layer(), + ws2.next_layer()); + ws1.async_handshake("localhost", "/", + [](error_code){}); + ws2.async_accept([](error_code){}); + ioc.run(); + ioc.restart(); + flat_buffer b1; + auto mb = b1.prepare(65536); + std::memset(mb.data(), 0, mb.size()); + b1.commit(65536); + ws1.async_write(b1.data(), + [&](error_code, std::size_t){}); + BEAST_EXPECT( + ws1.impl_->wr_block.is_locked()); + ws1.async_read_some(net::mutable_buffer{}, + [&](error_code, std::size_t){}); + ioc.run(); + ioc.restart(); + flat_buffer b2; + ws2.async_read(b2, + [&](error_code, std::size_t){}); + ioc.run(); + } + //); + { echo_server es{log, kind::async}; net::io_context ioc;