From fd52df9206cf7b4aeb04b13df96931e903c09c2e Mon Sep 17 00:00:00 2001 From: Damian Jarek Date: Mon, 29 Apr 2019 14:12:46 +0200 Subject: [PATCH] Fix data race in test stream Resolve: #1594 Signed-off-by: Damian Jarek --- CHANGELOG.md | 6 ++++++ include/boost/beast/_experimental/test/impl/stream.ipp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e32a4df..f0fa0913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 254: + +* Fix data race in test::stream::connect + +-------------------------------------------------------------------------------- + Version 253: * Fix async_detect_ssl handler type diff --git a/include/boost/beast/_experimental/test/impl/stream.ipp b/include/boost/beast/_experimental/test/impl/stream.ipp index 38b8a8b2..2a26e91b 100644 --- a/include/boost/beast/_experimental/test/impl/stream.ipp +++ b/include/boost/beast/_experimental/test/impl/stream.ipp @@ -262,6 +262,9 @@ connect(stream& remote) { BOOST_ASSERT(! out_.lock()); BOOST_ASSERT(! remote.out_.lock()); + std::lock(in_->m, remote.in_->m); + std::lock_guard guard1{in_->m, std::adopt_lock}; + std::lock_guard guard2{remote.in_->m, std::adopt_lock}; out_ = remote.in_; remote.out_ = in_; in_->code = status::ok;