diff --git a/.travis.yml b/.travis.yml index c1875d28..2b7161bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,6 +62,25 @@ matrix: - libc++-dev - libc++abi-dev + # GCC 5.0, Valgrind + - os: linux + dist: trusty + compiler: g++-5 + env: + - VARIANT=beast_valgrind + - TOOLSET=gcc + - COMPILER=g++-5 + - CXXSTD=11 + addons: + apt: + packages: + - g++-5 + - libssl-dev + - valgrind + - *base_packages + sources: + - *base_sources + # Default g++ - os: linux compiler: g++ @@ -87,25 +106,6 @@ matrix: sources: - *base_sources - # GCC 5.0, Valgrind - - os: linux - dist: trusty - compiler: g++-5 - env: - - VARIANT=beast_valgrind - - TOOLSET=gcc - - COMPILER=g++-5 - - CXXSTD=11 - addons: - apt: - packages: - - g++-5 - - libssl-dev - - valgrind - - *base_packages - sources: - - *base_sources - # Clang 3.8, UBasan - os: linux compiler: clang++-3.8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 68efca35..5702cae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 273: + +* Squelch spurious websocket timer assert + +-------------------------------------------------------------------------------- + Version 272: * Add BEAST_THROWS diff --git a/include/boost/beast/websocket/impl/stream_impl.hpp b/include/boost/beast/websocket/impl/stream_impl.hpp index 5bcd9c78..8940566c 100644 --- a/include/boost/beast/websocket/impl/stream_impl.hpp +++ b/include/boost/beast/websocket/impl/stream_impl.hpp @@ -451,7 +451,11 @@ struct stream::impl_type } else { - BOOST_ASSERT(! is_timer_set()); + // VFALCO This assert goes off when there's also + // a pending read with the timer set. The bigger + // fix is to give close its own timeout, instead + // of using the handshake timeout. + // BOOST_ASSERT(! is_timer_set()); } break; diff --git a/test/beast/websocket/timer.cpp b/test/beast/websocket/timer.cpp index 0c908cf8..e2b6e85d 100644 --- a/test/beast/websocket/timer.cpp +++ b/test/beast/websocket/timer.cpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace boost { namespace beast { @@ -85,10 +86,80 @@ struct timer_test : unit_test::suite test::run(ioc); } + // https://github.com/boostorg/beast/issues/1729 + void + testIssue1729() + { + { + net::io_context ioc; + stream ws1(ioc); + stream ws2(ioc); + test::connect(ws1.next_layer(), ws2.next_layer()); + + ws1.set_option(websocket::stream_base::timeout{ + std::chrono::milliseconds(50), + websocket::stream_base::none(), + false}); + + ws1.async_accept(net::detached); + ws2.async_handshake( + "localhost", "/", net::detached); + ioc.run(); + ioc.restart(); + + flat_buffer b; + error_code ec1, ec2; + ws1.async_close({}, + [&ec2](error_code ec) + { + ec2 = ec; + }); + ioc.run(); + BEAST_EXPECT( + ec1 == beast::error::timeout || + ec2 == beast::error::timeout); + } + { + net::io_context ioc; + stream ws1(ioc); + stream ws2(ioc); + test::connect(ws1.next_layer(), ws2.next_layer()); + + ws1.set_option(websocket::stream_base::timeout{ + std::chrono::milliseconds(50), + websocket::stream_base::none(), + false}); + + ws1.async_accept(net::detached); + ws2.async_handshake( + "localhost", "/", net::detached); + ioc.run(); + ioc.restart(); + + flat_buffer b; + error_code ec1, ec2; + ws1.async_read(b, + [&ec1](error_code ec, std::size_t) + { + ec1 = ec; + }); + ws1.async_close({}, + [&ec2](error_code ec) + { + ec2 = ec; + }); + ioc.run(); + BEAST_EXPECT( + ec1 == beast::error::timeout || + ec2 == beast::error::timeout); + } + } + void run() override { testIdlePing(); + testIssue1729(); } };