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/com_android_providers_media_FuseDaemon.cpp b/jni/com_android_providers_media_FuseDaemon.cpp
index a6a8d18..1633b99 100644
--- a/jni/com_android_providers_media_FuseDaemon.cpp
+++ b/jni/com_android_providers_media_FuseDaemon.cpp
@@ -15,7 +15,7 @@
*/
// Need to use LOGE_EX.
-#define LOG_TAG "FuseDaemon"
+#define LOG_TAG "FuseDaemonJNI"
#include <nativehelper/scoped_utf_chars.h>
@@ -49,12 +49,6 @@
daemon->Start(fd, string_path);
}
-void com_android_providers_media_FuseDaemon_stop(JNIEnv* env, jobject self, jlong java_daemon) {
- LOG(DEBUG) << "Stopping the FUSE daemon...";
- fuse::FuseDaemon* const daemon = reinterpret_cast<fuse::FuseDaemon*>(java_daemon);
- daemon->Stop();
-}
-
void com_android_providers_media_FuseDaemon_delete(JNIEnv* env, jobject self, jlong java_daemon) {
LOG(DEBUG) << "Destroying the FUSE daemon...";
fuse::FuseDaemon* const daemon = reinterpret_cast<fuse::FuseDaemon*>(java_daemon);
@@ -66,8 +60,6 @@
reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_new)},
{"native_start", "(JILjava/lang/String;)V",
reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_start)},
- {"native_stop", "(J)V",
- reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_stop)},
{"native_delete", "(J)V",
reinterpret_cast<void*>(com_android_providers_media_FuseDaemon_delete)}};
} // namespace