+2007-04-26 Miklos Szeredi <miklos@szeredi.hu>
+
+ * In multithreaded loop, use a semaphore instead of SIGHUP to wake
+ up the main thread on umount. This is more elegant, and works
+ even if signals are blocked.
+
2007-04-25 Miklos Szeredi <miklos@szeredi.hu>
* Improve mounting support in libfuse:
#include <string.h>
#include <unistd.h>
#include <signal.h>
+#include <semaphore.h>
#include <errno.h>
#include <sys/time.h>
struct fuse_session *se;
struct fuse_chan *prevch;
struct fuse_worker main;
+ sem_t finish;
int exit;
int error;
};
pthread_mutex_unlock(&mt->lock);
}
- pthread_kill(mt->main.thread_id, SIGHUP);
+ sem_post(&mt->finish);
pause();
return NULL;
mt.numavail = 0;
mt.main.thread_id = pthread_self();
mt.main.prev = mt.main.next = &mt.main;
+ sem_init(&mt.finish, 0, 0);
fuse_mutex_init(&mt.lock);
pthread_mutex_lock(&mt.lock);
err = fuse_start_thread(&mt);
pthread_mutex_unlock(&mt.lock);
if (!err) {
+ /* sem_wait() is interruptible */
while (!fuse_session_exited(se))
- pause();
+ sem_wait(&mt.finish);
for (w = mt.main.next; w != &mt.main; w = w->next)
pthread_cancel(w->thread_id);
}
pthread_mutex_destroy(&mt.lock);
+ sem_destroy(&mt.finish);
fuse_session_reset(se);
return err;
}