diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2022-01-31 05:09:18 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2022-01-31 05:09:18 +0000 |
commit | a6cae2083cdd3b28163ad5228054c3b5f44cc231 (patch) | |
tree | 46c23c484f8947698b9d52a291c769d78409ebd5 /sys/dev/kstat.c | |
parent | 25ece682b561cc0c243d0c7aa09ebbc08489bbf3 (diff) |
add kstat_remove so you can tear the struct apart before kstat_destroy
Diffstat (limited to 'sys/dev/kstat.c')
-rw-r--r-- | sys/dev/kstat.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/dev/kstat.c b/sys/dev/kstat.c index 11e3ed8dd0d..073f61a2c34 100644 --- a/sys/dev/kstat.c +++ b/sys/dev/kstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kstat.c,v 1.1 2020/07/06 03:56:51 dlg Exp $ */ +/* $OpenBSD: kstat.c,v 1.2 2022/01/31 05:09:17 dlg Exp $ */ /* * Copyright (c) 2020 David Gwynne <dlg@openbsd.org> @@ -627,6 +627,18 @@ kstat_install(struct kstat *ks) } void +kstat_remove(struct kstat *ks) +{ + rw_enter_write(&kstat_lock); + KASSERTMSG(ks->ks_state == KSTAT_S_INSTALLED, + "kstat %p %s:%u:%s:%u is not installed", ks, + ks->ks_provider, ks->ks_instance, ks->ks_name, ks->ks_unit); + + ks->ks_state = KSTAT_S_CREATED; + rw_exit_write(&kstat_lock); +} + +void kstat_destroy(struct kstat *ks) { rw_enter_write(&kstat_lock); |