summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-04-02 13:40:38 +0000
committerjhb <jhb@FreeBSD.org>2007-04-02 13:40:38 +0000
commit6d9ee961ef98540193347377e83fbc165737a272 (patch)
tree4e6115a8c2927105103c34784ed0cf9a8635026b /sys/kern
parentf7fd4a8556af48ddb2efb0b6e2a863d96b75fbd2 (diff)
downloadFreeBSD-src-6d9ee961ef98540193347377e83fbc165737a272.zip
FreeBSD-src-6d9ee961ef98540193347377e83fbc165737a272.tar.gz
Don't go to a whole lot of extra work to handle the race where the new
file descriptor is closed out from under us in kern_open(). This race is already handled and the file will be closed when kern_open() does an fdrop just before returning.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_syscalls.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 3a4ff54..d380943 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1024,31 +1024,8 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
- /*
- * There should be 2 references on the file, one from the descriptor
- * table, and one for us.
- *
- * Handle the case where someone closed the file (via its file
- * descriptor) while we were blocked. The end result should look
- * like opening the file succeeded but it was immediately closed.
- * We call vn_close() manually because we haven't yet hooked up
- * the various 'struct file' fields.
- */
- FILEDESC_LOCK(fdp);
+ FILEDESC_LOCK_FAST(fdp);
FILE_LOCK(fp);
- if (fp->f_count == 1) {
- mp = vp->v_mount;
- KASSERT(fdp->fd_ofiles[indx] != fp,
- ("Open file descriptor lost all refs"));
- FILE_UNLOCK(fp);
- FILEDESC_UNLOCK(fdp);
- VOP_UNLOCK(vp, 0, td);
- vn_close(vp, flags & FMASK, fp->f_cred, td);
- VFS_UNLOCK_GIANT(vfslocked);
- fdrop(fp, td);
- td->td_retval[0] = indx;
- return (0);
- }
fp->f_vnode = vp;
if (fp->f_data == NULL)
fp->f_data = vp;
@@ -1058,7 +1035,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
fp->f_seqcount = 1;
fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
FILE_UNLOCK(fp);
- FILEDESC_UNLOCK(fdp);
+ FILEDESC_UNLOCK_FAST(fdp);
VOP_UNLOCK(vp, 0, td);
if (flags & (O_EXLOCK | O_SHLOCK)) {
OpenPOWER on IntegriCloud