diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2007-05-29 13:34:15 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2007-05-29 13:34:15 +0000 |
commit | 84b4f9d5b5c5228a28dd9dda821e7b45e4dfc693 (patch) | |
tree | f22ede650874d7cbdaac3422b8723dc382299542 | |
parent | 1bf09e6bf76573942343f10e8e403777e59b042a (diff) |
lib: don't create new thread for each FORGET request...
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/fuse_loop_mt.c | 16 |
2 files changed, 20 insertions, 2 deletions
@@ -1,3 +1,9 @@ +2007-05-25 Miklos Szeredi <miklos@szeredi.hu> + + * lib: don't create new thread for each FORGET request. FORGET + messages sometimes caused so many threads to be created, that + process virtual memory space ran out. Reported by Chris AtLee + 2007-05-24 Miklos Szeredi <miklos@szeredi.hu> * lib: fix memory leak on thread creation failure in multithreaded diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index e9e04b3..7bcc1c2 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -8,6 +8,7 @@ #include "fuse_lowlevel.h" #include "fuse_misc.h" +#include "fuse_kernel.h" #include <stdio.h> #include <stdlib.h> @@ -64,6 +65,7 @@ static void *fuse_do_work(void *data) struct fuse_mt *mt = w->mt; while (!fuse_session_exited(mt->se)) { + int isforget = 0; struct fuse_chan *ch = mt->prevch; int res = fuse_chan_recv(&ch, w->buf, w->bufsize); if (res == -EINTR) @@ -81,7 +83,16 @@ static void *fuse_do_work(void *data) pthread_mutex_unlock(&mt->lock); return NULL; } - mt->numavail--; + + /* + * This disgusting hack is needed so that zillions of threads + * are not created on a burst of FORGET messages + */ + if (((struct fuse_in_header *) w->buf)->opcode == FUSE_FORGET) + isforget = 1; + + if (!isforget) + mt->numavail--; if (mt->numavail == 0) fuse_start_thread(mt); pthread_mutex_unlock(&mt->lock); @@ -89,7 +100,8 @@ static void *fuse_do_work(void *data) fuse_session_process(mt->se, w->buf, res, ch); pthread_mutex_lock(&mt->lock); - mt->numavail ++; + if (!isforget) + mt->numavail++; if (mt->numavail > 10) { if (mt->exit) { pthread_mutex_unlock(&mt->lock); |