summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaichi Hirono2016-11-14 18:31:21 -0600
committerDaichi Hirono2016-11-16 18:10:53 -0600
commit30e68088951f17ad54c1d15576835ff4eb622c4c (patch)
tree2798f1f86672712a3e16d35ca3e3bbf0c3046d09 /libappfuse/FuseBridgeLoop.cc
parent335502453d9b37c9c853dd3ac904d945b04e01ee (diff)
downloadplatform-system-core-30e68088951f17ad54c1d15576835ff4eb622c4c.tar.gz
platform-system-core-30e68088951f17ad54c1d15576835ff4eb622c4c.tar.xz
platform-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.cc23
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(
26 base::unique_fd dev_fd(raw_dev_fd); 26 base::unique_fd dev_fd(raw_dev_fd);
27 base::unique_fd proxy_fd(raw_proxy_fd); 27 base::unique_fd proxy_fd(raw_proxy_fd);
28 fuse::FuseBuffer buffer; 28 fuse::FuseBuffer buffer;
29 size_t open_count = 0;
29 30
30 LOG(DEBUG) << "Start fuse loop."; 31 LOG(DEBUG) << "Start fuse loop.";
31 while (true) { 32 while (true) {
@@ -71,8 +72,26 @@ bool FuseBridgeLoop::Start(
71 return false; 72 return false;
72 } 73 }
73 74
74 if (opcode == FUSE_INIT) { 75 switch (opcode) {
75 callback->OnMount(); 76 case FUSE_INIT:
77 callback->OnMount();
78 break;
79 case FUSE_OPEN:
80 if (buffer.response.header.error == fuse::kFuseSuccess) {
81 open_count++;
82 }
83 break;
84 case FUSE_RELEASE:
85 if (open_count != 0) {
86 open_count--;
87 } else {
88 LOG(WARNING) << "Unexpected FUSE_RELEASE before opening a file.";
89 break;
90 }
91 if (open_count == 0) {
92 return true;
93 }
94 break;
76 } 95 }
77 } 96 }
78} 97}