summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcheloha <cheloha@openbsd.org>2020-08-11 22:00:51 +0000
committercheloha <cheloha@openbsd.org>2020-08-11 22:00:51 +0000
commitefe63c19b26df40ec8cd6ad74d46ff155897865f (patch)
tree084e221988440bd30086e71e144f88d118f86b2e
parentPrioritize incoming certificate requests by the order of CERTEQ payloads (diff)
downloadwireguard-openbsd-efe63c19b26df40ec8cd6ad74d46ff155897865f.tar.xz
wireguard-openbsd-efe63c19b26df40ec8cd6ad74d46ff155897865f.zip
setitimer(2): write new timer value in one place
Rearrange the critical section in setitimer(2) to match that of getitimer(2). This will make it easier to merge the two critical sections in a subsequent diff. In particular, we want to write the new timer value in *one* place in the code, regardless of which timer we're setting. ok millert@
-rw-r--r--sys/kern/kern_time.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index aef1375ec10..8ecc848b61c 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.137 2020/08/11 18:29:58 cheloha Exp $ */
+/* $OpenBSD: kern_time.c,v 1.138 2020/08/11 22:00:51 cheloha Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -597,6 +597,10 @@ sys_setitimer(struct proc *p, void *v, register_t *retval)
}
if (itvp == 0)
return (0);
+
+ if (which != ITIMER_REAL)
+ mtx_enter(&itimer_mtx);
+
if (which == ITIMER_REAL) {
struct timespec cts;
@@ -607,12 +611,11 @@ sys_setitimer(struct proc *p, void *v, register_t *retval)
timeout_add(&pr->ps_realit_to, timo);
timespecadd(&aits.it_value, &cts, &aits.it_value);
}
- pr->ps_timer[ITIMER_REAL] = aits;
- } else {
- mtx_enter(&itimer_mtx);
- pr->ps_timer[which] = aits;
- mtx_leave(&itimer_mtx);
}
+ pr->ps_timer[which] = aits;
+
+ if (which != ITIMER_REAL)
+ mtx_leave(&itimer_mtx);
return (0);
}