aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-03-30 10:25:32 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-03-30 10:25:32 +0000
commit42f80e15c96ef559799a17c68964f2a86e5bc934 (patch)
tree0217c2ac8221bc35691f428f1a2243af0539d591
parent506d2d5491448fea5683ea8d34957b10e048847b (diff)
Use original logic to avoid race condition.
-rw-r--r--messagebus/src/vespa/messagebus/network/rpctarget.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/messagebus/src/vespa/messagebus/network/rpctarget.cpp b/messagebus/src/vespa/messagebus/network/rpctarget.cpp
index 58f1a6f0137..ea21010e21c 100644
--- a/messagebus/src/vespa/messagebus/network/rpctarget.cpp
+++ b/messagebus/src/vespa/messagebus/network/rpctarget.cpp
@@ -26,12 +26,13 @@ void
RPCTarget::resolveVersion(duration timeout, RPCTarget::IVersionHandler &handler)
{
bool shouldInvoke = false;
- ResolveState state = _state.load(std::memory_order_relaxed);
+ ResolveState state = _state.load(std::memory_order_acquire);
bool hasVersion = (state == VERSION_RESOLVED);
if ( ! hasVersion ) {
vespalib::MonitorGuard guard(_lock);
- if (state == PROCESSING_HANDLERS) {
- while (_state == PROCESSING_HANDLERS) {
+ state = _state.load(std::memory_order_relaxed);
+ if (state == VERSION_RESOLVED || state == PROCESSING_HANDLERS) {
+ while (_state.load(std::memory_order::memory_order_relaxed) == PROCESSING_HANDLERS) {
guard.wait();
}
hasVersion = true;