From c5dbcdce2d1942abb567d03bf9dafb74f06b5769 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Sun, 30 Mar 2025 22:43:09 +0200 Subject: Fix multi-threaded fuse session exit Issue with previous code was that fuse_session_exit() didn't wake up the semaphore in fuse_loop_mt.c. Lock, semaphore and all uses of checking for "exited" are now moved to struct fuse_session to have it available for the signal handler. This also removes internal fuse_session_reset() calls, as that makes testing hard. From git history I also don't see why it was added. Closes: https://github.com/libfuse/libfuse/issues/997 Signed-off-by: Bernd Schubert --- lib/fuse_i.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/fuse_i.h') diff --git a/lib/fuse_i.h b/lib/fuse_i.h index 48b8294..1f59944 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -10,6 +10,8 @@ #include "fuse_lowlevel.h" #include "util.h" +#include +#include #include #include #include @@ -55,7 +57,6 @@ struct fuse_notify_req { struct fuse_session { char *mountpoint; - volatile int exited; int fd; struct fuse_custom_io *io; struct mount_opts *mo; @@ -83,6 +84,11 @@ struct fuse_session { */ struct libfuse_version version; + /* thread synchronization */ + _Atomic bool mt_exited; + pthread_mutex_t mt_lock; + sem_t mt_finish; + /* true if reading requests from /dev/fuse are handled internally */ bool buf_reallocable; }; -- cgit v1.2.3