diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-01-14 20:01:24 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-01-14 20:01:24 +0000 |
commit | 2153d69672a90ba56e169319e9dbf27dc5bac466 (patch) | |
tree | 081b96d6d8ff6c3eada1ee33d0e20bf1a7ba8679 | |
parent | 49e022df8f7906aed5bb0bd3fbe8b8f374642198 (diff) | |
download | bcm5719-llvm-2153d69672a90ba56e169319e9dbf27dc5bac466.tar.gz bcm5719-llvm-2153d69672a90ba56e169319e9dbf27dc5bac466.zip |
Fix a race in the construction of future. This fixes http://llvm.org/bugs/show_bug.cgi?id=14934.
llvm-svn: 172456
-rw-r--r-- | libcxx/include/future | 6 | ||||
-rw-r--r-- | libcxx/src/future.cpp | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/libcxx/include/future b/libcxx/include/future index cf552a9f303..f4e6fec4f6c 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -470,7 +470,11 @@ public: {return (__state_ & __constructed) || (__exception_ != nullptr);} _LIBCPP_INLINE_VISIBILITY - void __set_future_attached() {__state_ |= __future_attached;} + void __set_future_attached() + { + lock_guard<mutex> __lk(__mut_); + __state_ |= __future_attached; + } _LIBCPP_INLINE_VISIBILITY bool __has_future_attached() const {return __state_ & __future_attached;} diff --git a/libcxx/src/future.cpp b/libcxx/src/future.cpp index feb37e42db4..7d9a5b5da69 100644 --- a/libcxx/src/future.cpp +++ b/libcxx/src/future.cpp @@ -78,8 +78,8 @@ __assoc_sub_state::set_value() throw future_error(make_error_code(future_errc::promise_already_satisfied)); #endif __state_ |= __constructed | ready; - __lk.unlock(); __cv_.notify_all(); + __lk.unlock(); } void |