diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2004-02-15 21:14:48 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2004-02-15 21:14:48 +0000 |
commit | 824c230543eae3766e5a429669e3b8fe19fa8e73 (patch) | |
tree | 3c8a98381c8d8b13347216fa13bccc35d944ff14 | |
parent | d3d228237561f16ad427ffaf3b036f2339ed0104 (diff) | |
download | FreeBSD-src-824c230543eae3766e5a429669e3b8fe19fa8e73.zip FreeBSD-src-824c230543eae3766e5a429669e3b8fe19fa8e73.tar.gz |
In fdcheckstd the descriptor table should never be shared, so just
KASSERT this rather than trying to deal with what happens when file
descriptors change out from under us.
-rw-r--r-- | sys/kern/kern_descrip.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index abaac90..dba542d 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1737,11 +1737,12 @@ fdcheckstd(td) struct filedesc *fdp; struct file *fp; register_t retval; - int fd, i, error, flags, devnull, extraref; + int fd, i, error, flags, devnull; fdp = td->td_proc->p_fd; if (fdp == NULL) return (0); + KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); devnull = -1; error = 0; for (i = 0; i < 3; i++) { @@ -1763,17 +1764,14 @@ fdcheckstd(td) * file descriptor table, so check it hasn't * changed before dropping the reference count. */ - extraref = 0; FILEDESC_LOCK(fdp); - if (fdp->fd_ofiles[fd] == fp) { - fdp->fd_ofiles[fd] = NULL; - fdunused(fdp, fd); - extraref = 1; - } + KASSERT(fdp->fd_ofiles[fd] == fp, + ("table not shared, how did it change?")); + fdp->fd_ofiles[fd] = NULL; + fdunused(fdp, fd); FILEDESC_UNLOCK(fdp); fdrop(fp, td); - if (extraref) - fdrop(fp, td); + fdrop(fp, td); break; } NDFREE(&nd, NDF_ONLY_PNBUF); |