diff options
author | rsc <devnull@localhost> | 2006-10-19 21:58:59 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-10-19 21:58:59 +0000 |
commit | 6fc7da3c529ca7c610e8172f5b02980c75597dd5 (patch) | |
tree | 6e06f1a96414ceb59a8016fb257b46b6f87f9a1c /src/cmd/vbackup | |
parent | 067d852abe242ee1d267bcc0d652cd6bb31b7e17 (diff) | |
download | plan9port-6fc7da3c529ca7c610e8172f5b02980c75597dd5.tar.gz plan9port-6fc7da3c529ca7c610e8172f5b02980c75597dd5.tar.bz2 plan9port-6fc7da3c529ca7c610e8172f5b02980c75597dd5.zip |
Fix a handful of small one-time memory leaks in vbackup,
and one per-package memory leak (in writethread).
Diffstat (limited to 'src/cmd/vbackup')
-rw-r--r-- | src/cmd/vbackup/queue.c | 6 | ||||
-rw-r--r-- | src/cmd/vbackup/queue.h | 1 | ||||
-rw-r--r-- | src/cmd/vbackup/vbackup.c | 21 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/cmd/vbackup/queue.c b/src/cmd/vbackup/queue.c index 91fa221d..d9fcd404 100644 --- a/src/cmd/vbackup/queue.c +++ b/src/cmd/vbackup/queue.c @@ -62,3 +62,9 @@ qclose(Queue *q) rwakeup(&q->r); qunlock(&q->lk); } + +void +qfree(Queue *q) +{ + vtfree(q); +} diff --git a/src/cmd/vbackup/queue.h b/src/cmd/vbackup/queue.h index 6b2317c3..00320069 100644 --- a/src/cmd/vbackup/queue.h +++ b/src/cmd/vbackup/queue.h @@ -20,3 +20,4 @@ Queue *qalloc(void); void qclose(Queue*); Block *qread(Queue*, u32int*); void qwrite(Queue*, Block*, u32int); +void qfree(Queue*); diff --git a/src/cmd/vbackup/vbackup.c b/src/cmd/vbackup/vbackup.c index 9e4c3b00..4c9fd386 100644 --- a/src/cmd/vbackup/vbackup.c +++ b/src/cmd/vbackup/vbackup.c @@ -284,6 +284,9 @@ threadmain(int argc, char **argv) * wait for processes to finish */ wlock(&endlk); + + qfree(qcmp); + qfree(qventi); if(statustime) print("# %T procs exited: %d blocks changed, %d read, %d written, %d skipped, %d copied\n", @@ -297,6 +300,8 @@ threadmain(int argc, char **argv) sysfatal("vtfileflush: %r"); if(vtfilegetentry(vfile, &e) < 0) sysfatal("vtfilegetentry: %r"); + vtfileunlock(vfile); + vtfileclose(vfile); b = vtcacheallocblock(c, VtDirType); if(b == nil) @@ -336,6 +341,19 @@ threadmain(int argc, char **argv) sysfatal("vtsync: %r"); if(statustime) print("# %T synced\n"); + + fsysclose(fsys); + diskclose(disk); + vtcachefree(zcache); + vtgoodbye(z); + // Leak here, because I can't seem to make + // the vtrecvproc exit. + // vtfreeconn(z); + free(tmpnam); + z = nil; + zcache = nil; + fsys = nil; + disk = nil; threadexitsall(nil); } @@ -416,6 +434,7 @@ writethread(void *v) } if(vtwritepacket(z, wr.score, wr.type, wr.p) < 0) sysfatal("vtwritepacket: %r"); + packetfree(wr.p); } } @@ -472,6 +491,7 @@ ventiproc(void *dummy) vtcachesetwrite(zcache, nil); for(i=0; i<nwritethread; i++) send(writechan, nil); + chanfree(writechan); if(statustime) print("# %T venti proc exiting - nsend %d nrecv %d\n", nsend, nrecv); runlock(&endlk); @@ -534,6 +554,7 @@ mountplace(char *dev) if(threadspawnl(fd, "sh", "sh", "-c", cmd, nil) < 0) sysfatal("exec mount|awk (to find mtpt of %s): %r", dev); /* threadspawnl closed p[1] */ + free(cmd); n = readn(p[0], buf, sizeof buf-1); close(p[0]); if(n <= 0) |