From 824c230543eae3766e5a429669e3b8fe19fa8e73 Mon Sep 17 00:00:00 2001 From: dwmalone Date: Sun, 15 Feb 2004 21:14:48 +0000 Subject: 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. --- sys/kern/kern_descrip.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'sys/kern') 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); -- cgit v1.1