diff options
author | Ties Bos <gitbisector@gmail.com> | 2012-09-10 22:07:26 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2012-09-10 22:07:26 -0400 |
commit | d4ccb0a943fb312d949726827d4e4e71e6a7a0bb (patch) | |
tree | 08c854a3e4c83c87780c5e302daae330eb50510b /src/cmd/9pfuse | |
parent | ba3110263311be872f4d1d1e11735d7afee1f61a (diff) | |
download | plan9port-d4ccb0a943fb312d949726827d4e4e71e6a7a0bb.tar.gz plan9port-d4ccb0a943fb312d949726827d4e4e71e6a7a0bb.tar.bz2 plan9port-d4ccb0a943fb312d949726827d4e4e71e6a7a0bb.zip |
9pfuse: fix memory leak, avoid memory explosion
Change is to handle FUSE_FORGET in main loop instead of separate thread for each as 10s of thousands can come in at once.
Fixes issue 104.
R=0intro, rsc
http://codereview.appspot.com/6498081
Diffstat (limited to 'src/cmd/9pfuse')
-rw-r--r-- | src/cmd/9pfuse/main.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c index 97783fb5..8fa56ff4 100644 --- a/src/cmd/9pfuse/main.c +++ b/src/cmd/9pfuse/main.c @@ -257,6 +257,7 @@ allocfh(CFid *fid) { return _alloc(fid, 0); } + uvlong allocnodeid(CFid *fid) { @@ -412,6 +413,7 @@ fuseforget(FuseMsg *m) fprint(2, "bad count in forget\n"); ff->ref = 1; freefusefid(ff); + freefusemsg(m); } /* @@ -1255,8 +1257,15 @@ fusedispatch(void *v) fusehandlers[fuselist[i].op] = fuselist[i].fn; } - while((m = recvp(fusechan)) != nil) - threadcreate(fusethread, m, STACK); + while((m = recvp(fusechan)) != nil) { + switch(m->hdr->opcode) { + case FUSE_FORGET: + fusehandlers[m->hdr->opcode](m); + break; + default: + threadcreate(fusethread, m, STACK); + } + } } void* |