Stop FUSE sessions properly
Now when we call ExternalStorageService#onEndSession
we block to ensure the FUSE loop has exited. This allows
us avoid racing mount and unmount events.
Typical usage: Vold#unmount -> ExternalStorageService#waitForExit
We don't use fuse_session_exit provided by libfuse because it needs
to be called from a signal handler or a FUSE operation handler.
Those are the only ways the loop can break out of a blocking read(2)
to accept the set 'exit' flag.
Test: atest AdoptableHostTest
Bug: 142109745
Change-Id: Ib0d525792eecd813ed4c7c30db5cb9d3053668c0
diff --git a/jni/FuseDaemon.h b/jni/FuseDaemon.h
index 89134a2..d3ff966 100644
--- a/jni/FuseDaemon.h
+++ b/jni/FuseDaemon.h
@@ -29,17 +29,12 @@
public:
FuseDaemon(JNIEnv* env, jobject mediaProvider);
- ~FuseDaemon() {
- // TODO(b/135341433): Ensure daemon is stopped and all resources are cleaned up
- }
+ ~FuseDaemon() = default;
+
/**
* Start the FUSE daemon loop that will handle filesystem calls.
*/
void Start(const int fd, const std::string& path);
- /**
- * Stop the FUSE daemon and clean up resources.
- */
- void Stop();
private:
FuseDaemon(const FuseDaemon&) = delete;