Allow concurrent websocket async ping and writes:

fix #271

This modifies the websocket stream implementation's composed
operations to allow caller-initiated asynchronous pings and
frame/message writes to take place at the same time.
This commit is contained in:
Vinnie Falco
2017-02-27 10:50:32 -05:00
parent 31cda067fa
commit faed9e57f2
8 changed files with 31 additions and 13 deletions
+2 -1
View File
@@ -190,7 +190,8 @@ operator()(error_code ec, bool again)
upcall:
if(d.ws.wr_block_ == &d)
d.ws.wr_block_ = nullptr;
d.ws.rd_op_.maybe_invoke();
d.ws.rd_op_.maybe_invoke() ||
d.ws.ping_op_.maybe_invoke();
d_.invoke(ec);
}
+3 -2
View File
@@ -133,7 +133,7 @@ operator()(error_code ec, bool again)
{
// suspend
d.state = 2;
d.ws.wr_op_.template emplace<
d.ws.ping_op_.template emplace<
ping_op>(std::move(*this));
return;
}
@@ -188,7 +188,8 @@ operator()(error_code ec, bool again)
upcall:
if(d.ws.wr_block_ == &d)
d.ws.wr_block_ = nullptr;
d.ws.rd_op_.maybe_invoke();
d.ws.rd_op_.maybe_invoke() ||
d.ws.wr_op_.maybe_invoke();
d_.invoke(ec);
}
+2 -1
View File
@@ -673,7 +673,8 @@ operator()(error_code ec,
upcall:
if(d.ws.wr_block_ == &d)
d.ws.wr_block_ = nullptr;
d.ws.wr_op_.maybe_invoke();
d.ws.ping_op_.maybe_invoke() ||
d.ws.wr_op_.maybe_invoke();
d_.invoke(ec);
}
+14 -4
View File
@@ -280,7 +280,10 @@ operator()(error_code ec,
d.fh.op = opcode::cont;
if(d.ws.wr_block_ == &d)
d.ws.wr_block_ = nullptr;
if(d.ws.rd_op_.maybe_invoke())
// Allow outgoing control frames to
// be sent in between message frames:
if(d.ws.rd_op_.maybe_invoke() ||
d.ws.ping_op_.maybe_invoke())
{
d.state = do_maybe_suspend;
d.ws.get_io_service().post(
@@ -382,7 +385,10 @@ operator()(error_code ec,
d.fh.op = opcode::cont;
BOOST_ASSERT(d.ws.wr_block_ == &d);
d.ws.wr_block_ = nullptr;
if(d.ws.rd_op_.maybe_invoke())
// Allow outgoing control frames to
// be sent in between message frames:
if(d.ws.rd_op_.maybe_invoke() ||
d.ws.ping_op_.maybe_invoke())
{
d.state = do_maybe_suspend;
d.ws.get_io_service().post(
@@ -452,7 +458,10 @@ operator()(error_code ec,
d.fh.rsv1 = false;
BOOST_ASSERT(d.ws.wr_block_ == &d);
d.ws.wr_block_ = nullptr;
if(d.ws.rd_op_.maybe_invoke())
// Allow outgoing control frames to
// be sent in between message frames:
if(d.ws.rd_op_.maybe_invoke() ||
d.ws.ping_op_.maybe_invoke())
{
d.state = do_maybe_suspend;
d.ws.get_io_service().post(
@@ -529,7 +538,8 @@ operator()(error_code ec,
upcall:
if(d.ws.wr_block_ == &d)
d.ws.wr_block_ = nullptr;
d.ws.rd_op_.maybe_invoke();
d.ws.rd_op_.maybe_invoke() ||
d.ws.ping_op_.maybe_invoke();
d_.invoke(ec);
}