mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 12:27:44 +02:00
Fix timer on websocket upgrade in examples
fix #1091, fix #1240, fix #1253
This commit is contained in:
@ -3,6 +3,7 @@ Version 184:
|
||||
* Remove extraneous function
|
||||
* Fix some typos
|
||||
* Add BOOST_BEAST_USE_STD_STRING_VIEW
|
||||
* Fix timer on websocket upgrade in examples
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
* ([issue 1233]) Use [@boost:/doc/html/core/empty_value.html `boost::empty_value`]
|
||||
|
||||
* ([issue 1091]) Fix timer on websocket upgrade in examples
|
||||
|
||||
* Workaround for http-server-fast and libstdc++
|
||||
|
||||
|
||||
|
@ -811,6 +811,10 @@ public:
|
||||
if(ec && ec != boost::asio::error::operation_aborted)
|
||||
return fail(ec, "timer");
|
||||
|
||||
// Check if this has been upgraded to Websocket
|
||||
if(timer_.expires_at() == (std::chrono::steady_clock::time_point::min)())
|
||||
return;
|
||||
|
||||
// Verify that the timer really expired since the deadline may have moved.
|
||||
if(timer_.expiry() <= std::chrono::steady_clock::now())
|
||||
return derived().do_timeout();
|
||||
@ -842,6 +846,10 @@ public:
|
||||
// See if it is a WebSocket Upgrade
|
||||
if(websocket::is_upgrade(req_))
|
||||
{
|
||||
// Make timer expire immediately, by setting expiry to time_point::min we can detect
|
||||
// the upgrade to websocket in the timer handler
|
||||
timer_.expires_at((std::chrono::steady_clock::time_point::min)());
|
||||
|
||||
// Transfer the stream to a new WebSocket session
|
||||
return make_websocket_session(
|
||||
derived().release_stream(),
|
||||
|
@ -621,6 +621,10 @@ public:
|
||||
if(ec && ec != boost::asio::error::operation_aborted)
|
||||
return fail(ec, "timer");
|
||||
|
||||
// Check if this has been upgraded to Websocket
|
||||
if(timer_.expires_at() == (std::chrono::steady_clock::time_point::min)())
|
||||
return;
|
||||
|
||||
// Verify that the timer really expired since the deadline may have moved.
|
||||
if(timer_.expiry() <= std::chrono::steady_clock::now())
|
||||
{
|
||||
@ -658,6 +662,10 @@ public:
|
||||
// See if it is a WebSocket Upgrade
|
||||
if(websocket::is_upgrade(req_))
|
||||
{
|
||||
// Make timer expire immediately, by setting expiry to time_point::min we can detect
|
||||
// the upgrade to websocket in the timer handler
|
||||
timer_.expires_at((std::chrono::steady_clock::time_point::min)());
|
||||
|
||||
// Create a WebSocket websocket_session by transferring the socket
|
||||
std::make_shared<websocket_session>(
|
||||
std::move(socket_))->do_accept(std::move(req_));
|
||||
|
Reference in New Issue
Block a user