summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-12-29 20:44:46 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-12-29 20:44:46 +0000
commite7d5dd7e56ad195038d7246a45d3ccb34f3cafe6 (patch)
tree84a3f93ec42896d54903cb61dee71abddf833633
parentCreate a large thread pool when running core tests (diff)
downloadnetfs-e7d5dd7e56ad195038d7246a45d3ccb34f3cafe6.tar.bz2
netfs-e7d5dd7e56ad195038d7246a45d3ccb34f3cafe6.tar.xz
netfs-e7d5dd7e56ad195038d7246a45d3ccb34f3cafe6.zip
Have flush() wait on each BG operation in turn without holding _lock, BG operations themselves will remove themselves from the set upon completion
-rw-r--r--netfs/fuse/fuseFiles.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp
index eb80531..8aed188 100644
--- a/netfs/fuse/fuseFiles.cpp
+++ b/netfs/fuse/fuseFiles.cpp
@@ -30,12 +30,12 @@ FuseApp::OpenFile::wait() const
void
FuseApp::OpenFile::flush()
{
- Lock(_lock);
- while (!bg.empty()) {
- auto wi = bg.begin();
- auto w = wi->second;
- bg.erase(w);
- // bg operations are void, so no need to actually get the return value
+ auto first = [this]() {
+ SharedLock(_lock);
+ return bg.empty() ? nullptr : bg.begin()->second;
+ };
+ while (auto w = first()) {
+ // background operations are void, so no need to actually get the return value
w->throwLocalException();
}
}