diff options
author | Daichi Hirono <hirono@google.com> | 2016-11-15 09:31:21 +0900 |
---|---|---|
committer | Daichi Hirono <hirono@google.com> | 2016-11-17 09:10:53 +0900 |
commit | 30e68088951f17ad54c1d15576835ff4eb622c4c (patch) | |
tree | 2798f1f86672712a3e16d35ca3e3bbf0c3046d09 /libappfuse/FuseBridgeLoop.cc | |
parent | 335502453d9b37c9c853dd3ac904d945b04e01ee (diff) | |
download | system_core-30e68088951f17ad54c1d15576835ff4eb622c4c.tar.gz system_core-30e68088951f17ad54c1d15576835ff4eb622c4c.tar.bz2 system_core-30e68088951f17ad54c1d15576835ff4eb622c4c.zip |
Stops the loop when all files are closed.
The CL changes FuseBridgeLoop so that it exits when all files opened on
the AppFuse mount point are closed. Note that the client code will
unmount the FUSE mount point after the loop exits.
Bug: 32260320
Test: libappfuse_test
Change-Id: I4965fbb48de8a280c6306e70757a07376b1956a7
Diffstat (limited to 'libappfuse/FuseBridgeLoop.cc')
-rw-r--r-- | libappfuse/FuseBridgeLoop.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/libappfuse/FuseBridgeLoop.cc b/libappfuse/FuseBridgeLoop.cc index acb963cfc..beee4a6f5 100644 --- a/libappfuse/FuseBridgeLoop.cc +++ b/libappfuse/FuseBridgeLoop.cc @@ -26,6 +26,7 @@ bool FuseBridgeLoop::Start( base::unique_fd dev_fd(raw_dev_fd); base::unique_fd proxy_fd(raw_proxy_fd); fuse::FuseBuffer buffer; + size_t open_count = 0; LOG(DEBUG) << "Start fuse loop."; while (true) { @@ -71,8 +72,26 @@ bool FuseBridgeLoop::Start( return false; } - if (opcode == FUSE_INIT) { - callback->OnMount(); + switch (opcode) { + case FUSE_INIT: + callback->OnMount(); + break; + case FUSE_OPEN: + if (buffer.response.header.error == fuse::kFuseSuccess) { + open_count++; + } + break; + case FUSE_RELEASE: + if (open_count != 0) { + open_count--; + } else { + LOG(WARNING) << "Unexpected FUSE_RELEASE before opening a file."; + break; + } + if (open_count == 0) { + return true; + } + break; } } } |