Logo Search packages:      
Sourcecode: fuse version File versions

int fuse_session_loop_mt ( struct fuse_session *  se  ) 

Enter a multi-threaded event loop

Parameters:
se the session
Returns:
0 on success, -1 on error

Definition at line 182 of file fuse_loop_mt.c.

References fuse_session_exited(), fuse_session_loop_mt(), fuse_session_next_chan(), and fuse_session_reset().

Referenced by fuse_loop_mt(), fuse_loop_mt_proc(), and fuse_session_loop_mt().

{
      int err;
      struct fuse_mt mt;
      struct fuse_worker *w;

      memset(&mt, 0, sizeof(struct fuse_mt));
      mt.se = se;
      mt.prevch = fuse_session_next_chan(se, NULL);
      mt.error = 0;
      mt.numworker = 0;
      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))
                  sem_wait(&mt.finish);

            for (w = mt.main.next; w != &mt.main; w = w->next)
                  pthread_cancel(w->thread_id);
            mt.exit = 1;
            pthread_mutex_unlock(&mt.lock);

            while (mt.main.next != &mt.main)
                  fuse_join_worker(&mt, mt.main.next);

            err = mt.error;
      }

      pthread_mutex_destroy(&mt.lock);
      sem_destroy(&mt.finish);
      fuse_session_reset(se);
      return err;
}


Generated by  Doxygen 1.6.0   Back to index