summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2019-07-15 04:11:03 +0000
committervisa <visa@openbsd.org>2019-07-15 04:11:03 +0000
commit8994f64af411fc832c7f1ee3934cc414321f1e81 (patch)
tree1661d715021b879f81d9287839e05c7488543130 /sys/kern/sys_pipe.c
parentsync (diff)
downloadwireguard-openbsd-8994f64af411fc832c7f1ee3934cc414321f1e81.tar.xz
wireguard-openbsd-8994f64af411fc832c7f1ee3934cc414321f1e81.zip
Do not relock fdp in fdrelease(). This prevents unnecessary locking
in the common case. OK mpi@
Diffstat (limited to 'sys/kern/sys_pipe.c')
-rw-r--r--sys/kern/sys_pipe.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 9fecf1b6df6..91df07fdcaf 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.92 2019/07/14 10:21:11 semarie Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.93 2019/07/15 04:11:03 visa Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -177,15 +177,18 @@ dopipe(struct proc *p, int *ufds, int flags)
fdinsert(fdp, fds[1], cloexec, wf);
error = copyout(fds, ufds, sizeof(fds));
- if (error != 0) {
+ if (error == 0) {
+ fdpunlock(fdp);
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_STRUCT))
+ ktrfds(p, fds, 2);
+#endif
+ } else {
+ /* fdrelease() unlocks fdp. */
fdrelease(p, fds[0]);
+ fdplock(fdp);
fdrelease(p, fds[1]);
}
-#ifdef KTRACE
- else if (KTRPOINT(p, KTR_STRUCT))
- ktrfds(p, fds, 2);
-#endif
- fdpunlock(fdp);
FRELE(rf, p);
FRELE(wf, p);