Refactor read_op + fail_op

This commit is contained in:
Vinnie Falco
2017-08-13 10:59:23 -07:00
parent 3652137718
commit fa087e19f1
12 changed files with 456 additions and 570 deletions

View File

@ -12,6 +12,7 @@ WebSocket:
* Refactor fail_op
* Refactor read_op
* Refactor close_op
* Refactor read_op + fail_op
--------------------------------------------------------------------------------

View File

@ -54,12 +54,6 @@ public:
*/
using const_buffers_type = boost::asio::mutable_buffers_1;
/** The type used to represent the mutable input sequence as a list of buffers.
This buffer sequence is guaranteed to have length 1.
*/
using mutable_data_type = boost::asio::mutable_buffers_1;
/** The type used to represent the output sequence as a list of buffers.
This buffer sequence is guaranteed to have length 1.
@ -107,13 +101,6 @@ public:
const_buffers_type
data() const;
/** Get a list of mutable buffers that represent the input sequence.
@note These buffers remain valid across subsequent calls to `prepare`.
*/
mutable_data_type
mutable_data();
/// Set the input and output sequences to size 0
void
reset();

View File

@ -35,15 +35,6 @@ data() const ->
return {in_, dist(in_, out_)};
}
inline
auto
flat_static_buffer_base::
mutable_data() ->
mutable_data_type
{
return {in_, dist(in_, out_)};
}
inline
void
flat_static_buffer_base::

View File

@ -50,27 +50,6 @@ data() const ->
return result;
}
inline
auto
static_buffer_base::
mutable_data() ->
mutable_data_type
{
using boost::asio::mutable_buffer;
mutable_data_type result;
if(in_off_ + in_size_ <= capacity_)
{
result[0] = mutable_buffer{begin_ + in_off_, in_size_};
result[1] = mutable_buffer{begin_, 0};
}
else
{
result[0] = mutable_buffer{begin_ + in_off_, capacity_ - in_off_};
result[1] = mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)};
}
return result;
}
inline
auto
static_buffer_base::

View File

@ -54,10 +54,6 @@ public:
using const_buffers_type =
std::array<boost::asio::mutable_buffer, 2>;
/// The type used to represent the mutable input sequence as a list of buffers.
using mutable_data_type =
std::array<boost::asio::mutable_buffer, 2>;
/// The type used to represent the output sequence as a list of buffers.
using mutable_buffers_type =
std::array<boost::asio::mutable_buffer, 2>;
@ -98,11 +94,6 @@ public:
const_buffers_type
data() const;
/** Get a list of mutable buffers that represent the input sequence.
*/
mutable_data_type
mutable_data();
/** Get a list of buffers that represent the output sequence, with the given size.
@param size The number of bytes to request.

View File

@ -251,7 +251,7 @@ close(close_reason const& cr, error_code& ec)
rd_close_ = true;
auto const mb = buffer_prefix(
clamp(rd_.fh.len),
rd_.buf.mutable_data());
rd_.buf.data());
if(rd_.fh.len > 0 && rd_.fh.mask)
detail::mask_inplace(mb, rd_.key);
detail::read_close(cr_, mb, code);

View File

@ -202,10 +202,7 @@ operator()(error_code ec, std::size_t)
upcall:
BOOST_ASSERT(d.ws.wr_block_ == d.tok);
d.ws.wr_block_.reset();
d.ws.close_op_.maybe_invoke() ||
d.ws.ping_op_.maybe_invoke() ||
d.ws.wr_op_.maybe_invoke();
d_.invoke(ec, 0);
d_.invoke(ec);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -177,11 +177,13 @@ open(role_type role)
rd_.cont = false;
rd_.done = true;
// Can't clear this because accept uses it
//rd_.buf.consume(rd_.buf.size());
//rd_.buf.reset();
rd_.fh.fin = false;
rd_close_ = false;
wr_close_ = false;
wr_block_.reset();
rd_block_.reset();
cr_.code = close_code::none;
ping_data_ = nullptr; // should be nullptr on close anyway
wr_.cont = false;
@ -240,6 +242,8 @@ reset()
wr_close_ = false;
wr_.cont = false;
wr_block_.reset();
rd_block_.reset();
cr_.code = close_code::none;
ping_data_ = nullptr; // should be nullptr on close anyway
}

View File

@ -230,12 +230,15 @@ class stream
bool rd_close_; // read close frame
bool wr_close_; // sent close frame
token wr_block_; // op currenly writing
token rd_block_; // op currenly reading
ping_data* ping_data_; // where to put the payload
detail::pausation rd_op_; // paused read op
detail::pausation wr_op_; // paused write op
detail::pausation ping_op_; // paused ping op
detail::pausation close_op_; // paused close op
detail::pausation r_rd_op_; // paused read op (read)
detail::pausation r_close_op_; // paused close op (read)
close_reason cr_; // set from received close frame
rd_t rd_; // read state
wr_t wr_; // write state

View File

@ -105,7 +105,6 @@ public:
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
}
ba.commit(2);
BEAST_EXPECT(buffer_size(ba.data()) == buffer_size(ba.mutable_data()));
BEAST_EXPECT(ba.size() == x + y + z);
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
BEAST_EXPECT(to_string(ba.data()) == s);

View File

@ -105,7 +105,6 @@ public:
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
}
ba.commit(2);
BEAST_EXPECT(buffer_size(ba.data()) == buffer_size(ba.mutable_data()));
BEAST_EXPECT(ba.size() == x + y + z);
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
BEAST_EXPECT(to_string(ba.data()) == s);