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
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4f9ea2c..67d90a5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS
@@ -35,6 +35,7 @@ Rob Pike <robpike@gmail.com> Russ Cox <rsc@swtch.com> Sean McKean <smckean83@gmail.com> +Ties Bos <gitbisector@gmail.com> Tim Newsham <tim.newsham@gmail.com> Tony Lainson <t.lainson@gmail.com> Venkatesh Srinivas <extrudedaluminiu@gmail.com>
diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c index 97783fb..8fa56ff 100644 --- a/src/cmd/9pfuse/main.c +++ b/src/cmd/9pfuse/main.c
@@ -257,6 +257,7 @@ { return _alloc(fid, 0); } + uvlong allocnodeid(CFid *fid) { @@ -412,6 +413,7 @@ fprint(2, "bad count in forget\n"); ff->ref = 1; freefusefid(ff); + freefusemsg(m); } /* @@ -1255,8 +1257,15 @@ 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*