From e7d5dd7e56ad195038d7246a45d3ccb34f3cafe6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 29 Dec 2017 20:44:46 +0000 Subject: Have flush() wait on each BG operation in turn without holding _lock, BG operations themselves will remove themselves from the set upon completion --- netfs/fuse/fuseFiles.cpp | 12 ++++++------ 1 file 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(); } } -- cgit v1.2.3