Fix buffer lifetime in websocket write

This commit is contained in:
Vinnie Falco
2017-07-15 18:31:43 -07:00
parent cee3bff060
commit 47c07b0a59
2 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,11 @@ Version 83:
* Add flat_static_buffer::mutable_data * Add flat_static_buffer::mutable_data
* Add buffer_front * Add buffer_front
WebSocket
* Add wstest compression option
* Fix buffer lifetime in websocket write
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Version 82: Version 82:

View File

@ -401,20 +401,21 @@ loop:
} }
d.fh.fin = ! more; d.fh.fin = ! more;
d.fh.len = n; d.fh.len = n;
detail::fh_streambuf fh_buf; detail::write<
detail::write<flat_static_buffer_base>(fh_buf, d.fh); flat_static_buffer_base>(d.fh_buf, d.fh);
d.ws.wr_.cont = ! d.fin; d.ws.wr_.cont = ! d.fin;
// Send frame // Send frame
d.step = more ? d.step = more ?
do_deflate + 1 : do_deflate + 2; do_deflate + 1 : do_deflate + 2;
boost::asio::async_write(d.ws.stream_, boost::asio::async_write(d.ws.stream_,
buffer_cat(fh_buf.data(), b), buffer_cat(d.fh_buf.data(), b),
std::move(*this)); std::move(*this));
return; return;
} }
case do_deflate + 1: case do_deflate + 1:
BOOST_ASSERT(d.ws.wr_block_ == &d); BOOST_ASSERT(d.ws.wr_block_ == &d);
d.fh_buf.consume(d.fh_buf.size());
d.ws.wr_block_ = nullptr; d.ws.wr_block_ = nullptr;
d.fh.op = detail::opcode::cont; d.fh.op = detail::opcode::cont;
d.fh.rsv1 = false; d.fh.rsv1 = false;