diff options
author | jlemon <jlemon@FreeBSD.org> | 2001-12-14 19:02:57 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2001-12-14 19:02:57 +0000 |
commit | f7af5c6f927c1530abc7ebc578a2dc820dcdfe7e (patch) | |
tree | 28e79809ce4038d9f6e51f6b039b4f301a20bd10 /sys | |
parent | 1b6efabb9089079541ab9a7a4cfa29b4549d39b8 (diff) | |
download | FreeBSD-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.c | 11 |
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; |