mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Fix race in close frames during reads
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
WebSocket
|
||||
|
||||
* 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));
|
||||
return;
|
||||
}
|
||||
// fall through
|
||||
d.ws.wr_block_ = &d;
|
||||
// [[fallthrough]]
|
||||
|
||||
case 1:
|
||||
// send close frame
|
||||
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
||||
d.state = 99;
|
||||
d.ws.wr_close_ = true;
|
||||
BOOST_ASSERT(! d.ws.wr_block_);
|
||||
d.ws.wr_block_ = &d;
|
||||
boost::asio::async_write(d.ws.stream_,
|
||||
d.fb.data(), std::move(*this));
|
||||
return;
|
||||
|
||||
case 2:
|
||||
BOOST_ASSERT(! d.ws.wr_block_);
|
||||
d.ws.wr_block_ = &d;
|
||||
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(
|
||||
bind_handler(std::move(*this), ec));
|
||||
return;
|
||||
|
||||
case 3:
|
||||
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
||||
if(d.ws.failed_ || d.ws.wr_close_)
|
||||
{
|
||||
// call handler
|
||||
|
Reference in New Issue
Block a user