[Nut-upsdev] [nut-commits] svn commit r1074 - in trunk: .

Peter Selinger selinger at mathstat.dal.ca
Sat Aug 25 13:30:48 UTC 2007


Arjen de Korte wrote:
> 
> >> * drivers/usbhid-ups.c:
> >> - The behaviour of reconnect is now depending on the 'reloadmatcher'
> >> variable. By default, it uses 'exact' matches, but this can be
> >> changed to 'regex', which me ans that it will use MODE_OPEN instead
> >> of MODE_REOPEN. Essentially, it will beha ve exactly like starting
> >> again.
> >
> > Shouldn't the default be to use exact matching whenever possible, and
> > fall back to MODE_OPEN matching on failure (i.e., the currently
> > intended behavior)?
> 
> No. In some applications where you are certain that nobody touched the
> hardware (datacenter, remote configurations) you'd rather get an error,
> than that the driver is silently 'correcting' the situation, which may
> yield the correct result, but also might start monitoring a different UPS
> that happens to be plugged in the USB port, but is not being monitored
> yet, nor is providing power for your server.
>
> > The other choice, which a user might request, is
> > strict matching, i.e., to enforce exact matching all the time. I am
> > not sure why anyone would request exact matching to be specifically
> > turned off. Do I interpret the above log message correctly that the
> > user now only has a choice between always-lax and always-strict
> > matching?
> 
> Yes. What is open to discussion, is what the default should be. I also
> pointed that out.

Okay, perhaps I am misunderstanding. There are three possible
behaviors on reconnection:

(1) *always* match strictly the same device, and give an error otherwise,
(2) *always* match laxly; do not even attempt strict matching, even if
    it would succeed.
(3) try strict matching first, and use lax matching as a fallback.

Option (3) used to be the default, and in fact it used to be the only
possible behavior.

If I understand your log message correctly, you have now eliminated
option (3) altogether, giving the user a choice only between (1) and (2). 

This would be a very bad idea in my opinion. I cannot think of any
situation where behavior (2) would be preferable to behavior (3).

Clearly, if the exact matching device is available, we should try to
connect to it. The question should only be what to do if the exact
matching device is not available. Therefore, the user should be given
a choice between (1) and (3), and not between (1) and (2).

Which one of these should be the default is another discussion. 

> >> * drivers/libhid.c:
> >> - The 'exact' matcher now also matches the Bus too (this won't
> >> change as long as the USB plug is not removed). If you don't like
> >> this, use the 'regex' matcher instead.
> > Ooh, I don't like this last one at all. One of the main reasons a
> > device might get disconnected is that the user physically unplugs it
> > while it is in operation, and then plugs it back in. Unlikely in a
> > server configuration, but not so unlikely for desktops.
> 
> I think you missed the following message, which explains why I think this
> is a good idea after all:
> 
> http://lists.alioth.debian.org/pipermail/nut-upsdev/2007-August/002471.html

OK, I read that message after the other one. However, you message only
makes sense if option (3) has already been eliminated. For the reasons
above, I think option (3) should not be eliminated. 

Strict bus matching may (or may not) be desirable for behavior (1). In
fact, I think it is not desirable, because even for a server, being
able to move the UPS to different physical locations can be useful.
If the user wants a specific bus, they can use the existing -x bus
option, as has always been the case.

Strict bus matching is irrelevant for behavior (2).

Strict bus matching is a really *bad* idea for behavior (3). It
basically means that no users, including desktop users, have the
option to move their UPS to a different port any more. 


As I said in some previous message, I think the most useful behavior
would be to make (3) the default behavior, allow (1) as an option,
chain the regex-matcher to the reopen-matcher, and *not* add the bus
to the reopen-matcher. In other words:

hd = HIDOpenDevice(&udev, &curDevice, reopen_matcher, MODE_REOPEN);
if (hd == NULL && USER_HAS_NOT_REQUESTED_STRICT_MATCHING) {
   /* reopening failed, try opening new device */
   hd = HIDOpenDevice(&udev, &curDevice, regex_matcher, MODE_OPEN);
}
if (hd == NULL) {
   return 0;
}

-- Peter



More information about the Nut-upsdev mailing list