[Nut-upsdev] Changes to upscli_connect
Arjen de Korte
nut+devel at de-korte.org
Tue Jun 28 18:29:25 UTC 2011
Citeren Frédéric Bohé <fredericbohe op eaton.com>:
> I am currently working on the nut scanner. For detecting available upsd
> on the network, I rely on upscli_connect. The problem with this function
> is that it calls a blocking "connect" function.
This is a serious problem, not only for the nut-scanner but for
basically all nut clients we currently bundle.
> So the nut-scanner is
> blocked while waiting for the TCP timeout when trying to connect to an
> IP without upsd available . Since this timeout may be rather long (3
> minutes on my host), I would like to add a timeout parameter to
> upscli_connect.
I don't think this is a good idea.
> I propose to add a upscli_tryconnect function accepting a timeout
> parameter, which will be the copy of the current upscli_connect + the
> management of the timeout. The upscli_connect will be only a wrapper on
> top of upscli_tryconnect, calling it without timeout.
> Please let me know if this makes sense to you.
The upscli_connnect() call should not block. If it does, that is a
problem that needs fixing, rather than adding an timeout. On what kind
of system did you test this? If I attempt to connect upsmon to a
non-existing server socket, the following is shown (-DDD):
0.001902 Trying to connect to UPS [myups op localhost]
0.002667 UPS [myups op localhost]: connect failed: Connection
failure: Network is unreachable
0.002690 do_notify: ntype 0x0005 (COMMBAD)
0.002704 Communications with UPS myups op localhost lost
Best regards, Arjen
--
Please keep list traffic on the list (off-list replies will be rejected)
More information about the Nut-upsdev
mailing list