summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2012-06-11 19:51:27 +0000
committerpjd <pjd@FreeBSD.org>2012-06-11 19:51:27 +0000
commitb903b5753dfa4750266fd0e1dd06ba451ad7076d (patch)
tree4f87e0d23345a7cf2c9b599e70ff6f87c9ab23a0 /sys/kern/kern_descrip.c
parent2042e99ed8ccdef6450180d8e17ea548b55394d3 (diff)
downloadFreeBSD-src-b903b5753dfa4750266fd0e1dd06ba451ad7076d.zip
FreeBSD-src-b903b5753dfa4750266fd0e1dd06ba451ad7076d.tar.gz
Move the code around a bit to move two parts of code duplicated from
kern_close() close together. Discussed with: kib Tested by: pho MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 1fbf3e9..65f7124 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -874,6 +874,17 @@ do_dup(struct thread *td, int flags, int old, int new,
KASSERT(fp == fdp->fd_ofiles[old], ("old fd has been modified"));
KASSERT(old != new, ("new fd is same as old"));
+ delfp = fdp->fd_ofiles[new];
+
+ /*
+ * Duplicate the source descriptor.
+ */
+ fdp->fd_ofiles[new] = fp;
+ fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] &~ UF_EXCLOSE;
+ if (new > fdp->fd_lastfile)
+ fdp->fd_lastfile = new;
+ *retval = new;
+
/*
* Save info on the descriptor being overwritten. We cannot close
* it without introducing an ownership race for the slot, since we
@@ -881,7 +892,6 @@ do_dup(struct thread *td, int flags, int old, int new,
*
* XXX this duplicates parts of close().
*/
- delfp = fdp->fd_ofiles[new];
holdleaders = 0;
if (delfp != NULL && td->td_proc->p_fdtol != NULL) {
/*
@@ -893,15 +903,6 @@ do_dup(struct thread *td, int flags, int old, int new,
}
/*
- * Duplicate the source descriptor.
- */
- fdp->fd_ofiles[new] = fp;
- fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] &~ UF_EXCLOSE;
- if (new > fdp->fd_lastfile)
- fdp->fd_lastfile = new;
- *retval = new;
-
- /*
* If we dup'd over a valid file, we now own the reference to it
* and must dispose of it using closef() semantics (as if a
* close() were performed on it).
OpenPOWER on IntegriCloud