summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarc Balmer <mbalmer@cvs.openbsd.org>2006-12-21 12:47:58 +0000
committerMarc Balmer <mbalmer@cvs.openbsd.org>2006-12-21 12:47:58 +0000
commit32fd0bf250421ff2d7b4d4203d870159b1d42375 (patch)
tree4bc2e4d723353af01cf28bcf1719178d7546e4a9 /sys
parentbb7a9f16f85a1bab6d96b9efcee3a3ed8a971e70 (diff)
Change the semantics of kern.watchdog.auto slightly: If kern.watchdog.auto is
set to 0, the watchdog will not be retriggered by the kernel *and* it will not be disabled at system shutdown time (before it got disabled at system shutdown time.) ok markus mickey mk
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_watchdog.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/kern_watchdog.c b/sys/kern/kern_watchdog.c
index b58d1fec115..cb48d10b8dc 100644
--- a/sys/kern/kern_watchdog.c
+++ b/sys/kern/kern_watchdog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_watchdog.c,v 1.6 2006/09/19 21:43:13 mk Exp $ */
+/* $OpenBSD: kern_watchdog.c,v 1.7 2006/12/21 12:47:57 mbalmer Exp $ */
/*
* Copyright (c) 2003 Markus Friedl. All rights reserved.
@@ -35,6 +35,7 @@ int (*wdog_ctl_cb)(void *, int) = NULL;
void *wdog_ctl_cb_arg = NULL;
int wdog_period = 0;
int wdog_auto = 1;
+void *wdog_cookie;
struct timeout wdog_timeout;
void
@@ -46,7 +47,7 @@ wdog_register(void *cb_arg, int (*cb)(void *, int))
wdog_ctl_cb = cb;
wdog_ctl_cb_arg = cb_arg;
timeout_set(&wdog_timeout, wdog_tickle, NULL);
- shutdownhook_establish(wdog_shutdown, NULL);
+ wdog_cookie = shutdownhook_establish(wdog_shutdown, NULL);
}
void
@@ -94,6 +95,13 @@ sysctl_wdog(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
error = sysctl_int(oldp, oldlenp, newp, newlen, &wdog_auto);
if (error)
return (error);
+ if (wdog_auto && wdog_cookie == NULL)
+ wdog_cookie = shutdownhook_establish(wdog_shutdown,
+ NULL);
+ else if (!wdog_auto && wdog_cookie) {
+ shutdownhook_disestablish(wdog_cookie);
+ wdog_cookie = NULL;
+ }
break;
default:
return (EINVAL);