Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jun 2012 19:51:27 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r236911 - head/sys/kern
Message-ID:  <201206111951.q5BJpRDP006439@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Mon Jun 11 19:51:27 2012
New Revision: 236911
URL: http://svn.freebsd.org/changeset/base/236911

Log:
  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

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Mon Jun 11 19:48:55 2012	(r236910)
+++ head/sys/kern/kern_descrip.c	Mon Jun 11 19:51:27 2012	(r236911)
@@ -874,6 +874,17 @@ do_dup(struct thread *td, int flags, int
 	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
 	 *
 	 * 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
 	}
 
 	/*
-	 * 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).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206111951.q5BJpRDP006439>