Fix race in test::pipe

This commit is contained in:
Vinnie Falco
2017-07-29 13:03:34 -07:00
parent 009d4f38ab
commit cd2f2b56d0
2 changed files with 5 additions and 4 deletions

View File

@ -2,6 +2,7 @@ Version 95:
* Tidy up Travis build scripts * Tidy up Travis build scripts
* Move scripts to build/ * Move scripts to build/
* Fix race in test::pipe
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -296,8 +296,8 @@ read_op_impl<Handler, Buffers>::operator()()
s_.in_.b.consume(bytes_transferred); s_.in_.b.consume(bytes_transferred);
auto& s = s_; auto& s = s_;
Handler h{std::move(h_)}; Handler h{std::move(h_)};
lock.unlock();
s.in_.op.reset(nullptr); s.in_.op.reset(nullptr);
lock.unlock();
++s.nread; ++s.nread;
s.ios_.post(bind_handler(std::move(h), s.ios_.post(bind_handler(std::move(h),
error_code{}, bytes_transferred)); error_code{}, bytes_transferred));
@ -307,8 +307,8 @@ read_op_impl<Handler, Buffers>::operator()()
BOOST_ASSERT(s_.in_.eof); BOOST_ASSERT(s_.in_.eof);
auto& s = s_; auto& s = s_;
Handler h{std::move(h_)}; Handler h{std::move(h_)};
lock.unlock();
s.in_.op.reset(nullptr); s.in_.op.reset(nullptr);
lock.unlock();
++s.nread; ++s.nread;
s.ios_.post(bind_handler(std::move(h), s.ios_.post(bind_handler(std::move(h),
boost::asio::error::eof, 0)); boost::asio::error::eof, 0));
@ -477,11 +477,11 @@ write_some(
auto const bytes_transferred = auto const bytes_transferred =
buffer_copy(out_.b.prepare(n), buffers); buffer_copy(out_.b.prepare(n), buffers);
out_.b.commit(bytes_transferred); out_.b.commit(bytes_transferred);
lock.unlock();
if(out_.op) if(out_.op)
out_.op.get()->operator()(); out_.op.get()->operator()();
else else
out_.cv.notify_all(); out_.cv.notify_all();
lock.unlock();
++nwrite; ++nwrite;
ec.assign(0, ec.category()); ec.assign(0, ec.category());
return bytes_transferred; return bytes_transferred;
@ -515,11 +515,11 @@ async_write_some(ConstBufferSequence const& buffers,
auto const bytes_transferred = auto const bytes_transferred =
buffer_copy(out_.b.prepare(n), buffers); buffer_copy(out_.b.prepare(n), buffers);
out_.b.commit(bytes_transferred); out_.b.commit(bytes_transferred);
lock.unlock();
if(out_.op) if(out_.op)
out_.op.get()->operator()(); out_.op.get()->operator()();
else else
out_.cv.notify_all(); out_.cv.notify_all();
lock.unlock();
++nwrite; ++nwrite;
ios_.post(bind_handler(init.completion_handler, ios_.post(bind_handler(init.completion_handler,
error_code{}, bytes_transferred)); error_code{}, bytes_transferred));