summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2004-07-05 19:39:06 +0000
committerderaadt <deraadt@openbsd.org>2004-07-05 19:39:06 +0000
commit08fbe7e75d41606a090381ee7e96854ab1976565 (patch)
treedd2547731cb40a7c033b2df98f883b55345d1da9
parentUse strtonum() instead of assigning the value of strtoul() to a uid_t/gid_t. (diff)
downloadwireguard-openbsd-08fbe7e75d41606a090381ee7e96854ab1976565.tar.xz
wireguard-openbsd-08fbe7e75d41606a090381ee7e96854ab1976565.zip
do not queue events when no daemon running. flush all events on last close.
ok tedu
-rw-r--r--sys/dev/hotplug.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/hotplug.c b/sys/dev/hotplug.c
index 425cc4462af..6f47fa5ee65 100644
--- a/sys/dev/hotplug.c
+++ b/sys/dev/hotplug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hotplug.c,v 1.1 2004/05/30 08:11:26 grange Exp $ */
+/* $OpenBSD: hotplug.c,v 1.2 2004/07/05 19:39:06 deraadt Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -86,6 +86,9 @@ hotplug_device_detach(enum devclass class, char *name)
int
hotplug_put_event(struct hotplug_event *he)
{
+ if (opened == 0)
+ return (0);
+
if (evqueue_count == HOTPLUG_MAXEVENTS) {
printf("hotplug: event lost, queue full\n");
return (1);
@@ -131,6 +134,10 @@ hotplugopen(dev_t dev, int flag, int mode, struct proc *p)
int
hotplugclose(dev_t dev, int flag, int mode, struct proc *p)
{
+ struct hotplug_event he;
+
+ while (hotplug_get_event(&he) == 1)
+ ;
opened = 0;
return (0);