[Nut-upsdev] [Bug 535583] Excessive logging by apcsmart program

Arnaud Quette aquette.dev at gmail.com
Thu Apr 21 08:34:49 UTC 2011


Hi Lupe,

since we now have an apcsmart maintainer, I'm forwarding this issue to him.

@Michal: could you please have a look at this issue [1], and give us your
feeling?

cheers,
Arnaud
--
[1] https://bugs.launchpad.net/bugs/535583

2011/2/15 Lupe Christoph <lupe at lupe-christoph.de>

> On Tuesday, 2011-02-15 at 13:16:58 -0000, Arnaud Quette wrote:
>
> > this is not the problem. This code is in the smartmode() function of
> > apcsmart.c:
> > http://svn.debian.org/wsvn/nut/trunk/drivers/apcsmart.c
>
> > we see the 5 attempts to go to smart mode ('Y' command), but my aim is to
> > understand why it is failing, and how to cleanly solve this without
> > impacting support for other units.
>
> I found no code that does five attempts. But this code in main.c,
> starting on Line 618:
>
>        while (!exit_flag) {
>
>                struct timeval  timeout;
>
>                gettimeofday(&timeout, NULL);
>                timeout.tv_sec += poll_interval;
>
>                upsdrv_updateinfo();
>
>                while (!dstate_poll_fds(timeout, extrafd) && !exit_flag) {
>                        /* repeat until time is up or extrafd has data */
>
>
>
> upsdrv_updateinfo() calls smartmode().
>
> dstate_poll_fds() checks if there is any file descriptor that is
> "available". In our case:
>
> select(7, [4 5 6], NULL, NULL, {1, 999837}) = 1 (in [4], left {1, 999835})
>
> FD 4 is the serial line, which is passed to dstate_poll_fds() as
> extrafd.
>
> When there is data that can be read from the UPS no code in
> dstate_poll_fds() reads from extrafd, there is only code that reads
> from the other input FDs. The outer loop above also ignores extrafd.
> exit_flag is never set, so it continues. And because there is an active
> file descriptor, the select returns immediately (actually it takes two
> microseconds).
>
> The solution is to add code that reads all data from extrafd and discards
> it because nobody asked for it. I would also close and reopen the serial
> line in smartmode(). I would prepare a patch if I knew more about the
> I/O abstractions used in the nut driver code. Sorry.
>
> HTH,
> Lupe Christoph
> --
> | It is a well-known fact in any organisation that, if you want a job    |
> | done, you should give it to someone who is already very busy.          |
> | Terry Pratchett, "Unseen Academicals"                                  |
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20110421/a7ea7971/attachment.htm>


More information about the Nut-upsdev mailing list