summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_event.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2018-06-02 10:27:43 +0000
committermpi <mpi@openbsd.org>2018-06-02 10:27:43 +0000
commite19d53e76a47615a43b7017fba112b33916857f5 (patch)
tree7f7b957be7e490a1f8be94c6aed0b47ed5b6794a /sys/kern/kern_event.c
parentrestore one set of quotes i shouldn;t have removed; (diff)
downloadwireguard-openbsd-e19d53e76a47615a43b7017fba112b33916857f5.tar.xz
wireguard-openbsd-e19d53e76a47615a43b7017fba112b33916857f5.zip
Put file descriptors on shared data structures when they are completely
setup. LARVAL fd still exist, but they are no longer marked with a flag and no longer reachable via `fd_ofiles[]'. This allows us to simplifies a lot code grabbing new references to fds. All of this is now possible because dup2(2) refuses to clone LARVAL fds. Note that the `fdplock' could now be release in all open(2)-like syscalls, just like it is done in accept(2). With inputs from Mathieu -, visa@, guenther@ and art@ ok visa@, bluhm@
Diffstat (limited to 'sys/kern/kern_event.c')
-rw-r--r--sys/kern/kern_event.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index f306a33e669..eec989b4a22 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.89 2018/05/22 19:15:22 cheloha Exp $ */
+/* $OpenBSD: kern_event.c,v 1.90 2018/06/02 10:27:43 mpi Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -441,10 +441,9 @@ sys_kqueue(struct proc *p, void *v, register_t *retval)
int fd, error;
fdplock(fdp);
- error = falloc(p, 0, &fp, &fd);
- fdpunlock(fdp);
+ error = falloc(p, &fp, &fd);
if (error)
- return (error);
+ goto out;
fp->f_flag = FREAD | FWRITE;
fp->f_type = DTYPE_KQUEUE;
fp->f_ops = &kqueueops;
@@ -456,8 +455,11 @@ sys_kqueue(struct proc *p, void *v, register_t *retval)
if (fdp->fd_knlistsize < 0)
fdp->fd_knlistsize = 0; /* this process has a kq */
kq->kq_fdp = fdp;
- FILE_SET_MATURE(fp, p);
- return (0);
+ fdinsert(fdp, fd, 0, fp);
+ FRELE(fp, p);
+out:
+ fdpunlock(fdp);
+ return (error);
}
int