[ntp:hackers] ntp_io and io_closeclock()
David L. Mills
mills at udel.edu
Mon Dec 20 19:58:06 PST 2004
The protocol used to open a reference clock and link it in the active
list is fragile. It's easy under common misconfiguration to wind up with
a misleadin error message "internal error" when the driver shutdown
routine is called. On closer examination the message is superfluous and
no harm is done. The protocol is
1. Open the device. If it fails abort immediately.
2. Call io_addclock(). If it fails, close the device and abort.
3. On shutdown call io_closeclock(). Do not close the device as
io_closeclock() will close it.
The problem is, even if the configuration fails, the refclock_unpeer()
routine will call the driver shutdown routine and that will call
io_closeclock(). That routine will not find the device in the active
list and that's no harm. Drivers should be careful not to close the
device after io_closeclock() is called.
Drivermongers should check the code.
More information about the hackers