ted.unan...@gmail.com (Ted Unangst), 2010.12.11 (Sat) 21:54 (CET): > On Sat, Dec 11, 2010 at 2:11 PM, MERIGHI Marcus <mcmer-open...@tor.at> wrote: > > the latest modification of src/sys/dev/hotplug.c (1) changes hotplug(4) > > behaviour concerning devices that are attached before the hotplug device > > is opened (by hotplugd(8), for example). such devices are ignored in > > hotplug.c by hotplug_put_event because of !evqueue (line 92 in -current). > > > > since the commit messages says nothing about behaviour change I suggest > > the following patch to restore the old behaviour: > > > > Index: hotplug.c > > =================================================================== > > RCS file: /cvs/src/sys/dev/hotplug.c,v > > retrieving revision 1.10 > > diff -u -r1.10 hotplug.c > > --- hotplug.c 2 Dec 2010 04:12:35 -0000 1.10 > > +++ hotplug.c 11 Dec 2010 19:00:09 -0000 > > @@ -90,7 +90,8 @@ > > return (1); > > } > > if (!evqueue) > > - return (1); > > + evqueue = malloc(sizeof(*he) * HOTPLUG_MAXEVENTS, M_DEVBUF, > \ > > + M_WAITOK); > > > > evqueue[evqueue_head] = *he; > > evqueue_head = EVQUEUE_NEXT(evqueue_head); > > You can't do this, because sleeping in this function would be bad.
ACK > You shouldn't need to handle hotplug events before the daemon is > running, just have the normal startup scripts deal with it. The behaviour change in hotplug(4)/hotplugd(8) after your commit makes it more ``hot plug'', actually. What bothers me (but not many others, obviously) is the fact that the behaviour change is undocumented. Four places come to my mind: 1) a comment in hotplug.c with appropriate commit message. 2) hotplug(4) man page, ``When a device attaches or detaches, the corresponding event is queued'' should (suggestion) read ``Once the device is opened by userland, when a device attaches or detaches, the corresponding event is queued.'' (I am not a native speaker, so please correct me!) 3) hotplugd(8) man page, make ``The hotplugd daemon monitors the hotplug(4) pseudo-device, acting on signaled events by executing the scripts in the /etc/hotplug directory.'' read ``The hotplugd daemon opens the hotplug(4) pseudo-device and thus enables event signaling. It then monitors the device, acting on signaled events by executing the scripts in the /etc/hotplug directory.'' 4) http://www.openbsd.org/faq/current.html I'd gladly supply patches for any of these. > Not receiving old events actually prevents problems where the device > is both attached and detached before hotplugd is running. I did not think this through, obviously, thanks for explaining.