aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse_mt.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-08-15 13:19:07 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2005-08-15 13:19:07 +0000
commit178451d6f063c1054e7960fd628692d6d394f4cd (patch)
tree6f16a8dd77a0854dfdbe87fabd4c50a0c1f8f672 /lib/fuse_mt.c
parenta148242fb80fa2127fdaf41de63e2d81dc8006ef (diff)
downloadlibfuse-178451d6f063c1054e7960fd628692d6d394f4cd.tar.gz
fix
Diffstat (limited to 'lib/fuse_mt.c')
-rw-r--r--lib/fuse_mt.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/lib/fuse_mt.c b/lib/fuse_mt.c
index c6a6a03..accd6c4 100644
--- a/lib/fuse_mt.c
+++ b/lib/fuse_mt.c
@@ -6,7 +6,7 @@
See the file COPYING.LIB.
*/
-#include "fuse.h"
+#include "fuse_i.h"
#include "fuse_lowlevel.h"
#include <stdio.h>
@@ -71,6 +71,8 @@ static void mt_delete_context_key(void)
struct procdata {
struct fuse *f;
+ struct fuse_chan *prevch;
+ struct fuse_session *prevse;
fuse_processor_t proc;
void *data;
};
@@ -82,10 +84,25 @@ static void mt_session_proc(void *data, const char *buf, size_t len,
struct fuse_cmd *cmd = *(struct fuse_cmd **) buf;
(void) len;
- (void) ch;
+ cmd->ch = ch;
pd->proc(pd->f, cmd, pd->data);
}
+static void mt_session_exit(void *data, int val)
+{
+ struct procdata *pd = (struct procdata *) data;
+ if (val)
+ fuse_session_exit(pd->prevse);
+ else
+ fuse_session_reset(pd->prevse);
+}
+
+static int mt_session_exited(void *data)
+{
+ struct procdata *pd = (struct procdata *) data;
+ return fuse_session_exited(pd->prevse);
+}
+
static int mt_chan_receive(struct fuse_chan *ch, char *buf, size_t size)
{
struct fuse_cmd *cmd;
@@ -95,11 +112,18 @@ static int mt_chan_receive(struct fuse_chan *ch, char *buf, size_t size)
cmd = fuse_read_cmd(pd->f);
if (cmd == NULL)
- return -1;
+ return 0;
*(struct fuse_cmd **) buf = cmd;
- return 0;
+ return sizeof(cmd);
+}
+
+static int mt_chan_send(struct fuse_chan *ch, const struct iovec iov[],
+ size_t count)
+{
+ struct procdata *pd = (struct procdata *) fuse_chan_data(ch);
+ return fuse_chan_send(pd->prevch, iov, count);
}
int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data)
@@ -111,13 +135,18 @@ int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data)
struct fuse_chan *prevch = fuse_session_next_chan(prevse, NULL);
struct fuse_chan *ch;
struct fuse_session_ops sop = {
+ .exit = mt_session_exit,
+ .exited = mt_session_exited,
.process = mt_session_proc,
};
struct fuse_chan_ops cop = {
.receive = mt_chan_receive,
+ .send = mt_chan_send,
};
pd.f = f;
+ pd.prevch = prevch;
+ pd.prevse = prevse;
pd.proc = proc;
pd.data = data;
@@ -149,6 +178,9 @@ int fuse_loop_mt(struct fuse *f)
{
int res;
+ if (f == NULL)
+ return -1;
+
if (mt_create_context_key() != 0)
return -1;