mirror of
https://github.com/boostorg/beast.git
synced 2025-08-02 14:24:31 +02:00
Fix race in pings during reads
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
1.0.0-b30
|
||||||
|
|
||||||
|
WebSocket
|
||||||
|
|
||||||
|
* Fix race in pings during reads
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
1.0.0-b29
|
1.0.0-b29
|
||||||
|
|
||||||
* Fix compilation error in non-template class
|
* Fix compilation error in non-template class
|
||||||
|
@@ -146,24 +146,32 @@ operator()(error_code ec, bool again)
|
|||||||
boost::asio::error::operation_aborted));
|
boost::asio::error::operation_aborted));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// fall through
|
d.ws.wr_block_ = &d;
|
||||||
|
// [[fallthrough]]
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
// send ping frame
|
// send ping frame
|
||||||
|
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
||||||
d.state = 99;
|
d.state = 99;
|
||||||
BOOST_ASSERT(! d.ws.wr_block_);
|
|
||||||
d.ws.wr_block_ = &d;
|
|
||||||
boost::asio::async_write(d.ws.stream_,
|
boost::asio::async_write(d.ws.stream_,
|
||||||
d.fb.data(), std::move(*this));
|
d.fb.data(), std::move(*this));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
BOOST_ASSERT(! d.ws.wr_block_);
|
||||||
|
d.ws.wr_block_ = &d;
|
||||||
d.state = 3;
|
d.state = 3;
|
||||||
|
// The current context is safe but might not be
|
||||||
|
// the same as the one for this operation (since
|
||||||
|
// we are being called from a write operation).
|
||||||
|
// Call post to make sure we are invoked the same
|
||||||
|
// way as the final handler for this operation.
|
||||||
d.ws.get_io_service().post(
|
d.ws.get_io_service().post(
|
||||||
bind_handler(std::move(*this), ec));
|
bind_handler(std::move(*this), ec));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
|
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
||||||
if(d.ws.failed_ || d.ws.wr_close_)
|
if(d.ws.failed_ || d.ws.wr_close_)
|
||||||
{
|
{
|
||||||
// call handler
|
// call handler
|
||||||
|
@@ -985,6 +985,10 @@ public:
|
|||||||
<em>composed operation</em>. The program must ensure that the
|
<em>composed operation</em>. The program must ensure that the
|
||||||
stream performs no other writes until this operation completes.
|
stream performs no other writes until this operation completes.
|
||||||
|
|
||||||
|
If a close frame is sent or received before the ping frame is
|
||||||
|
sent, the completion handler will be called with the error
|
||||||
|
set to `boost::asio::error::operation_aborted`.
|
||||||
|
|
||||||
@param payload The payload of the ping message, which may be empty.
|
@param payload The payload of the ping message, which may be empty.
|
||||||
|
|
||||||
@param handler The handler to be called when the read operation
|
@param handler The handler to be called when the read operation
|
||||||
@@ -1078,6 +1082,10 @@ public:
|
|||||||
order to send a pong. The remote peer may use the receipt of a
|
order to send a pong. The remote peer may use the receipt of a
|
||||||
pong frame as an indication that the connection is not dead.
|
pong frame as an indication that the connection is not dead.
|
||||||
|
|
||||||
|
If a close frame is sent or received before the pong frame is
|
||||||
|
sent, the completion handler will be called with the error
|
||||||
|
set to `boost::asio::error::operation_aborted`.
|
||||||
|
|
||||||
@param payload The payload of the pong message, which may be empty.
|
@param payload The payload of the pong message, which may be empty.
|
||||||
|
|
||||||
@param handler The handler to be called when the read operation
|
@param handler The handler to be called when the read operation
|
||||||
|
Reference in New Issue
Block a user