mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +02:00
Fix race in close frames during reads
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
WebSocket
|
WebSocket
|
||||||
|
|
||||||
* Fix race in pings during reads
|
* Fix race in pings during reads
|
||||||
|
* Fix race in close frames during reads
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -147,25 +147,33 @@ 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 close frame
|
// send close frame
|
||||||
|
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
||||||
d.state = 99;
|
d.state = 99;
|
||||||
d.ws.wr_close_ = true;
|
d.ws.wr_close_ = true;
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user