Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Mar 2006 15:25:46 GMT
From:      Todd Miller <millert@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 93627 for review
Message-ID:  <200603201525.k2KFPkaO012910@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93627

Change 93627 by millert@millert_p3 on 2006/03/20 15:25:46

	In fdcopy() set newfdp->fd_freefile after the first loop
	over fdp instead of the loop over newfdp.  This means we
	never enter fdused() with fd_freefile == -1.  It also fixes
	a bug when fdp->fd_lastfile == -1.  Previously, if
	fdp->fd_lastfile was -1 newfdp->fd_freefile would get set
	to 1 instead of 0 since newfdp->fd_lastfile is initialized
	to 0 and newfdp->fd_freefile will not have been set in the
	first loop (which doesn't run at all in this case).
	It's not clear why newfdp->fd_freefile is -1 at this point.

Affected files ...

.. //depot/projects/trustedbsd/sebsd/sys/kern/kern_descrip.c#18 edit

Differences ...

==== //depot/projects/trustedbsd/sebsd/sys/kern/kern_descrip.c#18 (text+ko) ====

@@ -1604,17 +1604,15 @@
 				newfdp->fd_freefile = i;
 		}
 	}
+	newfdp->fd_cmask = fdp->fd_cmask;
 	FILEDESC_UNLOCK_FAST(fdp);
 	FILEDESC_LOCK(newfdp);
+	if (newfdp->fd_freefile == -1)
+		newfdp->fd_freefile = i;
 	for (i = 0; i <= newfdp->fd_lastfile; ++i)
 		if (newfdp->fd_ofiles[i] != NULL)
 			fdused(newfdp, i);
 	FILEDESC_UNLOCK(newfdp);
-	FILEDESC_LOCK_FAST(fdp);
-	if (newfdp->fd_freefile == -1)
-		newfdp->fd_freefile = i;
-	newfdp->fd_cmask = fdp->fd_cmask;
-	FILEDESC_UNLOCK_FAST(fdp);
 	return (newfdp);
 }
 



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