mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +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
|
* Remove extraneous function
|
||||||
* Fix some typos
|
* Fix some typos
|
||||||
* Add BOOST_BEAST_USE_STD_STRING_VIEW
|
* 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 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++
|
* Workaround for http-server-fast and libstdc++
|
||||||
|
|
||||||
|
|
||||||
|
@ -811,6 +811,10 @@ public:
|
|||||||
if(ec && ec != boost::asio::error::operation_aborted)
|
if(ec && ec != boost::asio::error::operation_aborted)
|
||||||
return fail(ec, "timer");
|
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.
|
// Verify that the timer really expired since the deadline may have moved.
|
||||||
if(timer_.expiry() <= std::chrono::steady_clock::now())
|
if(timer_.expiry() <= std::chrono::steady_clock::now())
|
||||||
return derived().do_timeout();
|
return derived().do_timeout();
|
||||||
@ -842,6 +846,10 @@ public:
|
|||||||
// See if it is a WebSocket Upgrade
|
// See if it is a WebSocket Upgrade
|
||||||
if(websocket::is_upgrade(req_))
|
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
|
// Transfer the stream to a new WebSocket session
|
||||||
return make_websocket_session(
|
return make_websocket_session(
|
||||||
derived().release_stream(),
|
derived().release_stream(),
|
||||||
|
@ -621,6 +621,10 @@ public:
|
|||||||
if(ec && ec != boost::asio::error::operation_aborted)
|
if(ec && ec != boost::asio::error::operation_aborted)
|
||||||
return fail(ec, "timer");
|
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.
|
// Verify that the timer really expired since the deadline may have moved.
|
||||||
if(timer_.expiry() <= std::chrono::steady_clock::now())
|
if(timer_.expiry() <= std::chrono::steady_clock::now())
|
||||||
{
|
{
|
||||||
@ -658,6 +662,10 @@ public:
|
|||||||
// See if it is a WebSocket Upgrade
|
// See if it is a WebSocket Upgrade
|
||||||
if(websocket::is_upgrade(req_))
|
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
|
// Create a WebSocket websocket_session by transferring the socket
|
||||||
std::make_shared<websocket_session>(
|
std::make_shared<websocket_session>(
|
||||||
std::move(socket_))->do_accept(std::move(req_));
|
std::move(socket_))->do_accept(std::move(req_));
|
||||||
|
Reference in New Issue
Block a user