summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-06-28 01:59:58 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-06-28 01:59:58 +0000
commit760935674b4c54f743c3d357264d07fdd56cfbaf (patch)
treec1caf16028961ebe102661ec8281227c8873bd8f /sys/kern
parent9c37e1f32dbe8da7496bb5fe00d00e9d3423541f (diff)
splhigh around ec_count fetches -- sorry art; ok aaron
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_evcount.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/kern/subr_evcount.c b/sys/kern/subr_evcount.c
index 4cccf3239d8..856b310114e 100644
--- a/sys/kern/subr_evcount.c
+++ b/sys/kern/subr_evcount.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_evcount.c,v 1.1 2004/06/28 01:34:46 aaron Exp $ */
+/* $OpenBSD: subr_evcount.c,v 1.2 2004/06/28 01:59:57 deraadt Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
* Copyright (c) 2004 Aaron Campbell <aaron@openbsd.org>
@@ -102,9 +102,9 @@ evcount_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
void *newp;
size_t newlen;
{
+ int error = 0, s, nintr, i;
struct evcount *ec;
- int error = 0;
- int nintr, i;
+ u_int64_t count;
if (newp != NULL)
return (EPERM);
@@ -134,7 +134,10 @@ evcount_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
if (ec == NULL)
return (ENOENT);
/* XXX - bogus cast to int, but we can't do better. */
- error = sysctl_rdint(oldp, oldlenp, NULL, (int)ec->ec_count);
+ s = splhigh();
+ count = ec->ec_count;
+ splx(s);
+ error = sysctl_rdint(oldp, oldlenp, NULL, (int)count);
break;
case KERN_INTRCNT_NAME:
if (ec == NULL)
@@ -165,12 +168,15 @@ void
evcount_timeout(void *v)
{
struct timeout *to = v;
+ int s;
+ s = splhigh();
if (evcount_next_sync == NULL)
evcount_next_sync = TAILQ_FIRST(&evcount_list);
evcount_sync(evcount_next_sync);
evcount_next_sync = TAILQ_NEXT(evcount_next_sync, next);
+ splx(s);
timeout_add(to, hz);
}
@@ -180,6 +186,7 @@ void
evcount_sync(struct evcount *ec)
{
#ifndef __LP64__
+ /* XXX race */
ec->ec_count += ec->ec_count32;
ec->ec_count32 = 0;
#endif