various bug fixes

This commit is contained in:
rsc 2004-05-14 15:14:21 +00:00
parent a796abef16
commit 1a8f27c350
14 changed files with 1236 additions and 9 deletions

View file

@ -86,19 +86,27 @@ fsunmount(Fsys *fs)
void
_fsdecref(Fsys *fs)
{
Fid *f, *next;
Fid *f, **l, *next;
qlock(&fs->lk);
--fs->ref;
//fprint(2, "fsdecref %p to %d\n", fs, fs->ref);
if(fs->ref == 0){
close(fs->fd);
/* trim the list down to just the first in each chunk */
for(l=&fs->freefid; *l; ){
if((*l)->fid%Fidchunk == 0)
l = &(*l)->next;
else
*l = (*l)->next;
}
/* now free the list */
for(f=fs->freefid; f; f=next){
next = f->next;
if(f->fid%Fidchunk == 0)
free(f);
free(f);
}
free(fs);
return;
}
qunlock(&fs->lk);
}

View file

@ -23,8 +23,11 @@ nsmount(char *name, char *aname)
fd = dial(addr, 0, 0, 0);
if(fd < 0){
werrstr("dial %s: %r", addr);
free(addr);
return nil;
}
free(addr);
fcntl(fd, F_SETFL, FD_CLOEXEC);
fs = fsmount(fd, aname);