diff options
-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; |