aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2022-01-29 22:12:42 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2022-02-13 13:07:08 +0000
commit809f3121be660ac9f0605dd347b41b1b5e9ab195 (patch)
treedb3ef235f50eb848fb95eafad90b51cbb816e266
parent893d20c95ade6ae4b6a514bb003457ce8f2959fd (diff)
downloadsrc-809f3121be660ac9f0605dd347b41b1b5e9ab195.tar.gz
src-809f3121be660ac9f0605dd347b41b1b5e9ab195.zip
fd: assign fd_freefile early when copying
This is to simplify an upcomming change.
-rw-r--r--sys/kern/kern_descrip.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 1dc0f1e647d6..feb35c28cba1 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -2356,13 +2356,13 @@ fdcopy(struct filedesc *fdp)
FILEDESC_SLOCK(fdp);
}
/* copy all passable descriptors (i.e. not kqueue) */
- newfdp->fd_freefile = -1;
+ newfdp->fd_freefile = fdp->fd_freefile;
for (i = 0; i <= lastfile; ++i) {
ofde = &fdp->fd_ofiles[i];
if (ofde->fde_file == NULL ||
(ofde->fde_file->f_ops->fo_flags & DFLAG_PASSABLE) == 0 ||
!fhold(ofde->fde_file)) {
- if (newfdp->fd_freefile == -1)
+ if (newfdp->fd_freefile == fdp->fd_freefile)
newfdp->fd_freefile = i;
continue;
}
@@ -2371,8 +2371,7 @@ fdcopy(struct filedesc *fdp)
filecaps_copy(&ofde->fde_caps, &nfde->fde_caps, true);
fdused_init(newfdp, i);
}
- if (newfdp->fd_freefile == -1)
- newfdp->fd_freefile = i;
+ MPASS(newfdp->fd_freefile != -1);
FILEDESC_SUNLOCK(fdp);
return (newfdp);
}