Lines Matching refs:mt

50 	struct fuse_mt *mt;
125 static int fuse_loop_start_thread(struct fuse_mt *mt);
130 struct fuse_mt *mt = w->mt;
132 while (!fuse_session_exited(mt->se)) {
137 res = fuse_session_receive_buf_int(mt->se, &w->fbuf, w->ch);
143 fuse_session_exit(mt->se);
144 mt->error = res;
149 pthread_mutex_lock(&mt->lock);
150 if (mt->exit) {
151 pthread_mutex_unlock(&mt->lock);
168 mt->numavail--;
169 if (mt->numavail == 0 && mt->numworker < mt->max_threads)
170 fuse_loop_start_thread(mt);
171 pthread_mutex_unlock(&mt->lock);
173 fuse_session_process_buf_int(mt->se, &w->fbuf, w->ch);
175 pthread_mutex_lock(&mt->lock);
177 mt->numavail++;
185 if (mt->max_idle != -1 && mt->numavail > mt->max_idle && mt->numworker > 1) {
186 if (mt->exit) {
187 pthread_mutex_unlock(&mt->lock);
191 mt->numavail--;
192 mt->numworker--;
193 pthread_mutex_unlock(&mt->lock);
201 pthread_mutex_unlock(&mt->lock);
204 sem_post(&mt->finish);
245 static struct fuse_chan *fuse_clone_chan(struct fuse_mt *mt)
264 masterfd = mt->se->fd;
279 static int fuse_loop_start_thread(struct fuse_mt *mt)
290 w->mt = mt;
293 if (mt->clone_fd) {
294 w->ch = fuse_clone_chan(mt);
299 mt->clone_fd = 0;
309 list_add_worker(w, &mt->main);
310 mt->numavail ++;
311 mt->numworker ++;
316 static void fuse_join_worker(struct fuse_mt *mt, struct fuse_worker *w)
319 pthread_mutex_lock(&mt->lock);
321 pthread_mutex_unlock(&mt->lock);
332 struct fuse_mt mt;
347 memset(&mt, 0, sizeof(struct fuse_mt));
348 mt.se = se;
349 mt.clone_fd = config->clone_fd;
350 mt.error = 0;
351 mt.numworker = 0;
352 mt.numavail = 0;
353 mt.max_idle = config->max_idle_threads;
354 mt.max_threads = config->max_threads;
355 mt.main.thread_id = pthread_self();
356 mt.main.prev = mt.main.next = &mt.main;
357 sem_init(&mt.finish, 0, 0);
358 pthread_mutex_init(&mt.lock, NULL);
360 pthread_mutex_lock(&mt.lock);
361 err = fuse_loop_start_thread(&mt);
362 pthread_mutex_unlock(&mt.lock);
366 sem_wait(&mt.finish);
368 pthread_mutex_lock(&mt.lock);
369 for (w = mt.main.next; w != &mt.main; w = w->next)
371 mt.exit = 1;
372 pthread_mutex_unlock(&mt.lock);
374 while (mt.main.next != &mt.main)
375 fuse_join_worker(&mt, mt.main.next);
377 err = mt.error;
380 pthread_mutex_destroy(&mt.lock);
381 sem_destroy(&mt.finish);