diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-01-06 18:56:49 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-01-06 18:56:49 +0000 |
commit | 3151fa7a647ba449868ca1731bdbd29d7f84797a (patch) | |
tree | d9dab77cf16305047747dc27b923f7b958b69e3b | |
parent | Read ICE communicator args from options (diff) | |
download | netfs-3151fa7a647ba449868ca1731bdbd29d7f84797a.tar.bz2 netfs-3151fa7a647ba449868ca1731bdbd29d7f84797a.tar.xz netfs-3151fa7a647ba449868ca1731bdbd29d7f84797a.zip |
Don't mix and match [a]sync read/write operations
Hopefully prevents deadlocking when async writes saturate the thread pool when
a read operation occurs.
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 858a0a9..e56ce0b 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -147,14 +147,21 @@ int FuseApp::read(const char *, char * buf, size_t s, off_t o, struct fuse_file_info * fi) { try { + auto cpy = [buf](const auto && data) { + memcpy(buf, &data.front(), data.size()); + return data.size(); + }; auto of = getProxy<OpenFilePtr>(fi->fh); auto remote = of->remote; - auto data = (fcr->Async) ? - waitOnWriteRangeAndThen<Buffer>(s, o, of, [o, s, &remote](const auto &){ - return remote->read(o, s); - }) : remote->read(o, s); - memcpy(buf, &data.front(), data.size()); - return data.size(); + if (fcr->Async) { + auto p = waitOnWriteRangeAndThen<std::future<Buffer>>(s, o, of, [o, s, &remote](const auto &){ + return remote->readAsync(o, s); + }); + return cpy(p.get()); + } + else { + return cpy(remote->read(o, s)); + } } catch (SystemError & e) { return -e.syserrno; |