aboutsummaryrefslogtreecommitdiff
path: root/lib/fuse_loop_mt.c
diff options
context:
space:
mode:
authorGravatar Miklos Szeredi <miklos@szeredi.hu>2007-05-29 13:34:15 +0000
committerGravatar Miklos Szeredi <miklos@szeredi.hu>2007-05-29 13:34:15 +0000
commit84b4f9d5b5c5228a28dd9dda821e7b45e4dfc693 (patch)
treef22ede650874d7cbdaac3422b8723dc382299542 /lib/fuse_loop_mt.c
parent1bf09e6bf76573942343f10e8e403777e59b042a (diff)
lib: don't create new thread for each FORGET request...
Diffstat (limited to 'lib/fuse_loop_mt.c')
-rw-r--r--lib/fuse_loop_mt.c16
1 files changed, 14 insertions, 2 deletions
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);