aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9pfuse
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-08-01 03:19:53 +0000
committerrsc <devnull@localhost>2006-08-01 03:19:53 +0000
commitbe8b4b397af631bad302ef2646477f228b4537b5 (patch)
tree0facefc960a9af702bab2df8df45077d464694a9 /src/cmd/9pfuse
parent0d5f0a724bc6ce5cb837afee442d7ecca470cf16 (diff)
downloadplan9port-be8b4b397af631bad302ef2646477f228b4537b5.tar.gz
plan9port-be8b4b397af631bad302ef2646477f228b4537b5.tar.bz2
plan9port-be8b4b397af631bad302ef2646477f228b4537b5.zip
free fuse messages
Diffstat (limited to 'src/cmd/9pfuse')
-rw-r--r--src/cmd/9pfuse/fuse.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c
index 9918994d..2a6d13a4 100644
--- a/src/cmd/9pfuse/fuse.c
+++ b/src/cmd/9pfuse/fuse.c
@@ -5,6 +5,7 @@ int fuseeof;
int fusebufsize;
int fusemaxwrite;
FuseMsg *fusemsglist;
+Lock fusemsglock;
int mountfuse(char *mtpt);
void unmountfuse(char *mtpt);
@@ -15,10 +16,13 @@ allocfusemsg(void)
FuseMsg *m;
void *vbuf;
+ lock(&fusemsglock);
if((m = fusemsglist) != nil){
fusemsglist = m->next;
+ unlock(&fusemsglock);
return m;
}
+ unlock(&fusemsglock);
m = emalloc(sizeof(*m) + fusebufsize);
vbuf = m+1;
m->buf = vbuf;
@@ -31,8 +35,10 @@ allocfusemsg(void)
void
freefusemsg(FuseMsg *m)
{
+ lock(&fusemsglock);
m->next = fusemsglist;
fusemsglist = m;
+ unlock(&fusemsglock);
}
FuseMsg*
@@ -234,6 +240,7 @@ replyfuse(FuseMsg *m, void *arg, int narg)
}
if(writev(fusefd, vec, nvec) < 0)
sysfatal("replyfuse: %r");
+ freefusemsg(m);
}
/*
@@ -251,6 +258,7 @@ replyfuseerrno(FuseMsg *m, int e)
fprint(2, "FUSE <- %#G\n", m->hdr, &hdr, 0);
if(write(fusefd, &hdr, sizeof hdr) < 0)
sysfatal("replyfuseerror: %r");
+ freefusemsg(m);
}
void
@@ -310,7 +318,6 @@ initfuse(char *mtpt)
rx.minor = FUSE_KERNEL_MINOR_VERSION;
rx.max_write = fusemaxwrite;
replyfuse(m, &rx, sizeof rx);
- freefusemsg(m);
}
/*