mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Use handshake_timeout
for closing handshake during read operations
Fixes #2999
This commit is contained in:
committed by
Mohammad Nejati
parent
1d8dfae490
commit
1f3c4089ab
@ -662,6 +662,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl.change_status(status::closing);
|
impl.change_status(status::closing);
|
||||||
|
impl.update_timer(this->get_executor());
|
||||||
|
|
||||||
if(! impl.wr_close)
|
if(! impl.wr_close)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <boost/beast/_experimental/test/tcp.hpp>
|
#include <boost/beast/_experimental/test/tcp.hpp>
|
||||||
#include <boost/beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace websocket {
|
namespace websocket {
|
||||||
@ -163,10 +165,46 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
testIssue2999()
|
||||||
|
{
|
||||||
|
net::io_context ioc;
|
||||||
|
|
||||||
|
// Use handshake_timeout for the closing handshake,
|
||||||
|
// which can occur in websocket::stream::async_read_some.
|
||||||
|
stream<test::stream> ws1(ioc);
|
||||||
|
stream<test::stream> ws2(ioc);
|
||||||
|
test::connect(ws1.next_layer(), ws2.next_layer());
|
||||||
|
ws1.async_handshake("test", "/", test::success_handler());
|
||||||
|
ws2.async_accept(test::success_handler());
|
||||||
|
test::run(ioc);
|
||||||
|
|
||||||
|
flat_buffer b;
|
||||||
|
ws1.set_option(stream_base::timeout{
|
||||||
|
std::chrono::milliseconds(50),
|
||||||
|
stream_base::none(),
|
||||||
|
false});
|
||||||
|
// add a close frame to the input
|
||||||
|
ws1.next_layer().append(string_view{
|
||||||
|
"\x88\x00", 2});
|
||||||
|
ws1.async_read(b, test::fail_handler(
|
||||||
|
beast::error::timeout));
|
||||||
|
// limit the write buffer so that writing
|
||||||
|
// the close frame will not complete during
|
||||||
|
// the call to ioc.run_one()
|
||||||
|
ws1.next_layer().write_size(1);
|
||||||
|
ioc.run_one();
|
||||||
|
ioc.restart();
|
||||||
|
std::this_thread::sleep_for(
|
||||||
|
std::chrono::milliseconds(100));
|
||||||
|
test::run(ioc);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
testTimeout();
|
testTimeout();
|
||||||
|
testIssue2999();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user