Make sure that closefid/closereq are called with a refcount of 1 when fid or request are not returned. (non-return should not be counted as return in refcount). Without the patch, the fid/req structure will leak in the error case. Notes: Wed Jun 16 13:29:43 EDT 2004 rsc thanks. i fixed the leak by adding a new closereq in those cases. the double incref is still necessary to make sure the fid isn't removed out from under us before we do the second incref. Reference: /n/sources/patch/applied/lib9p-leak Date: Wed Jun 16 19:30:14 CES 2004 Reviewed-by: rsc --- /sys/src/lib9p/fid.c Wed Jun 16 19:30:14 2004 +++ /sys/src/lib9p/fid.c Wed Jun 16 19:30:14 2004 @@ -44,12 +44,12 @@ f->pool = pool; incfidref(f); - incfidref(f); if(caninsertkey(pool->map, fid, f) == 0){ closefid(f); return nil; } + incfidref(f); return f; } --- /sys/src/lib9p/req.c Wed Jun 16 19:30:14 2004 +++ /sys/src/lib9p/req.c Wed Jun 16 19:30:14 2004 @@ -46,12 +46,12 @@ r->pool = pool; increqref(r); - increqref(r); if(caninsertkey(pool->map, tag, r) == 0){ closereq(r); return nil; } + increqref(r); return r; }