2 bugs in 3.14.4

View: New views
2 Messages — Rating Filter:   Alert me  

2 bugs in 3.14.4

by Roger Fujii :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There are 2 bugs in 3.14.4's handling of serial ups's.

The first is in src/drivers/apcsmart/smart.c

    UPSlinkCheck should have a write_unlock(ups) to match the write_lock(ups) it calls.

The second is in src/drivers/apcsmart/smartsetup.c

    apcsmart_ups_setup() should drain the serial line before it tries to send/receive
    data.  I added:

       for(;;) {
          char answer[10];
          *answer = 0;
          getline(answer, sizeof(answer), ups);
          if( *answer == 0 )
              break;
       }

    just before the first write(ups->fd, &a,1 );

--
Roger Fujii <rmf@...>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Apcupsd-users mailing list
Apcupsd-users@...
https://lists.sourceforge.net/lists/listinfo/apcupsd-users

Re: 2 bugs in 3.14.4

by Adam Kropelin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Roger Fujii wrote:
> There are 2 bugs in 3.14.4's handling of serial ups's.

Thanks for the review...

> The first is in src/drivers/apcsmart/smart.c
>
>    UPSlinkCheck should have a write_unlock(ups) to match the
> write_lock(ups) it calls.

The locking in UPSlinkCheck() is inverted so it's tricky to follow, but the
code is correct as written. UPSlinkCheck() is invoked with the ups lock
held. We unlock before the while() loop and re-lock again before returning.

> The second is in src/drivers/apcsmart/smartsetup.c
>
>    apcsmart_ups_setup() should drain the serial line before it tries
>    to send/receive data.

We flush the input queue at the end of apcsmart_ups_open() which is called
before apcsmart_ups_setup(), so I do not believe any additional flushing is
required.

--Adam


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Apcupsd-users mailing list
Apcupsd-users@...
https://lists.sourceforge.net/lists/listinfo/apcupsd-users