summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2001-12-14 19:02:57 +0000
committerjlemon <jlemon@FreeBSD.org>2001-12-14 19:02:57 +0000
commitf7af5c6f927c1530abc7ebc578a2dc820dcdfe7e (patch)
tree28e79809ce4038d9f6e51f6b039b4f301a20bd10 /sys
parent1b6efabb9089079541ab9a7a4cfa29b4549d39b8 (diff)
downloadFreeBSD-src-f7af5c6f927c1530abc7ebc578a2dc820dcdfe7e.zip
FreeBSD-src-f7af5c6f927c1530abc7ebc578a2dc820dcdfe7e.tar.gz
When removing kqueue descriptors from the descriptor table during a fork,
update fd_freefile and fd_lastfile as well, to keep things in sync. Pointed out by: Debbie Chu <dchu@juniper.net>
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_descrip.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index d5febf7..55bab63 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1100,10 +1100,15 @@ fdcopy(td)
* kq descriptors cannot be copied.
*/
if (newfdp->fd_knlistsize != -1) {
- fpp = newfdp->fd_ofiles;
- for (i = newfdp->fd_lastfile; i-- >= 0; fpp++) {
- if (*fpp != NULL && (*fpp)->f_type == DTYPE_KQUEUE)
+ fpp = &newfdp->fd_ofiles[newfdp->fd_lastfile];
+ for (i = newfdp->fd_lastfile; i >= 0; i--, fpp--) {
+ if (*fpp != NULL && (*fpp)->f_type == DTYPE_KQUEUE) {
*fpp = NULL;
+ if (i < newfdp->fd_freefile)
+ newfdp->fd_freefile = i;
+ }
+ if (*fpp == NULL && i == newfdp->fd_lastfile && i > 0)
+ newfdp->fd_lastfile--;
}
newfdp->fd_knlist = NULL;
newfdp->fd_knlistsize = -1;
OpenPOWER on IntegriCloud