From adb53db85f5c50e0cbf37ee45c109519b5d357b5 Mon Sep 17 00:00:00 2001 From: George Xie Date: Fri, 1 Feb 2019 19:24:49 -0800 Subject: [PATCH] bug fix in failover server, only error out if io error --- failover.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/failover.go b/failover.go index d5da586..0042611 100644 --- a/failover.go +++ b/failover.go @@ -88,7 +88,7 @@ func (s *FailoverSerialConn) serverRead(b []byte) (int, error) { } n, err := s.PacketReader.Read(b) if err != nil { - return n, err + return n, err //only real io errors are exposed } s.lock.Lock() locked = true @@ -115,7 +115,9 @@ func (s *FailoverSerialConn) serverRead(b []byte) (int, error) { pdu, err := rtu.GetPDU() if err != nil { debugf("failover serverRead internal GetPDU error : %v", err) - return n, err //bubbles formate up errors + s.misses = 0 + debugf("reset misses\n") + continue //throw away and read again } if rtu[0] == 0 { //zero slave id do not have a reply, so we won't expect one