Squelch spurious websocket timer assert

This commit is contained in:
Vinnie Falco
2019-10-09 11:58:55 -07:00
parent 045dfeb47f
commit bafce23853
4 changed files with 101 additions and 20 deletions

View File

@@ -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

View File

@@ -1,3 +1,9 @@
Version 273:
* Squelch spurious websocket timer assert
--------------------------------------------------------------------------------
Version 272:
* Add BEAST_THROWS

View File

@@ -451,7 +451,11 @@ struct stream<NextLayer, deflateSupported>::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;

View File

@@ -15,6 +15,7 @@
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/detached.hpp>
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<tcp::socket> ws1(ioc);
stream<tcp::socket> 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<tcp::socket> ws1(ioc);
stream<tcp::socket> 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();
}
};