From a13323d10b62bafec9075126be8fc5bc02de82f2 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 24 May 2007 18:51:08 +0000 Subject: [PATCH] fix memory leak on thread creation failure... --- ChangeLog | 9 +++++++++ lib/fuse_loop_mt.c | 2 ++ lib/fuse_signals.c | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 02e965b..0dde32d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-05-24 Miklos Szeredi + + * lib: fix memory leak on thread creation failure in multithreaded + event loop. Found by Chris AtLee + + * Filesystems (e.g. sshfs) failed to exit if SIGHUP handler is + SIG_IGN in the parent process. So install handler for SIGHUP even + in this case. Reported by Tim Walberg + 2007-05-21 Miklos Szeredi * Fix Oops or error if a regular file is created with mknod(2) on diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 8f5db89..27fea31 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -143,6 +143,8 @@ static int fuse_start_thread(struct fuse_mt *mt) pthread_sigmask(SIG_SETMASK, &oldset, NULL); if (res != 0) { fprintf(stderr, "fuse: error creating thread: %s\n", strerror(res)); + free(w->buf); + free(w); return -1; } list_add_worker(w, &mt->main); diff --git a/lib/fuse_signals.c b/lib/fuse_signals.c index 6154110..8291ea0 100644 --- a/lib/fuse_signals.c +++ b/lib/fuse_signals.c @@ -36,7 +36,8 @@ static int set_one_signal_handler(int sig, void (*handler)(int)) return -1; } - if (old_sa.sa_handler == SIG_DFL && + if ((old_sa.sa_handler == SIG_DFL || + (sig == SIGHUP && old_sa.sa_handler == SIG_IGN)) && sigaction(sig, &sa, NULL) == -1) { perror("fuse: cannot set signal handler"); return -1;