summaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-10-13 12:06:51 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-10-13 12:06:51 +0200
commit2887ea1516ab72e10612c192d1af3296f8af97f0 (patch)
treefebe9bb68264c80320635d8481d4b24a64d32fa7 /staging_vespalib
parent6c1483a1316bd4ef18674f8fb2461a1b49ef64c3 (diff)
Avoid that we miss a stop that happens while we are STARTING.
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/document_runnable.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/document_runnable.cpp b/staging_vespalib/src/vespa/vespalib/util/document_runnable.cpp
index a612d5652ff..11fbf9d1655 100644
--- a/staging_vespalib/src/vespa/vespalib/util/document_runnable.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/document_runnable.cpp
@@ -29,6 +29,7 @@ bool Runnable::stop()
{
vespalib::MonitorGuard monitor(_stateLock);
if (_state == STOPPING || _state == NOT_RUNNING) return false;
+ while (_state == STARTING) monitor.wait();
GetThread()->SetBreakFlag();
_state = STOPPING;
return onStop();
@@ -55,6 +56,7 @@ void Runnable::Run(FastOS_ThreadInterface*, void*)
// called even though about to stop for consistency)
if (_state == STARTING) {
_state = RUNNING;
+ monitor.broadcast();
}
}