summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-07-09 10:29:44 +0200
committerTor Egge <Tor.Egge@online.no>2021-07-09 10:40:23 +0200
commit1e69f8dbe5e22bbedfcb63e9ab317238c06e4dec (patch)
tree589ce807377c4f6ea51aca7e3d3d7a7f21828e96 /searchcore
parent4b5ca059eda0ab6f3c1fa0c718980d7a6e978288 (diff)
Eliminate race in flush engine unit test which caused premature wakeup.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/flushengine/flushengine_test.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
index d5823a8e055..13dcfb45dc9 100644
--- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
+++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
@@ -117,6 +117,7 @@ public:
search::SerialNum _oldestSerial;
search::SerialNum _currentSerial;
uint32_t _pendingDone;
+ uint32_t _taskDone;
std::mutex _lock;
vespalib::CountDownLatch _done;
FlushDoneHistory _flushDoneHistory;
@@ -131,6 +132,7 @@ public:
_oldestSerial(0),
_currentSerial(currentSerial),
_pendingDone(0u),
+ _taskDone(0u),
_lock(),
_done(targets.size()),
_flushDoneHistory()
@@ -143,6 +145,11 @@ public:
std::vector<IFlushTarget::SP>
getFlushTargets() override {
+ {
+ std::lock_guard<std::mutex> guard(_lock);
+ _pendingDone += _taskDone;
+ _taskDone = 0;
+ }
LOG(info, "SimpleHandler(%s)::getFlushTargets()", getName().c_str());
std::vector<IFlushTarget::SP> wrappedTargets;
for (const auto &target : _targets) {
@@ -154,7 +161,7 @@ public:
// Called once by flush engine thread for each task done
void taskDone() {
std::lock_guard<std::mutex> guard(_lock);
- ++_pendingDone;
+ ++_taskDone;
}
// Called by flush engine master thread after flush handler is