]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/sp.go
Fix RxLastNonPing setting
[nncp.git] / src / sp.go
index 1297c414cb3d5c175720fc0178fe3e21224fec40..37cf265ead11ac3588fcb66eab69f7641599cc9c 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -22,7 +22,6 @@ import (
        "crypto/subtle"
        "errors"
        "io"
-       "net"
        "os"
        "path/filepath"
        "sort"
@@ -606,7 +605,6 @@ func (state *SPState) StartWorkers(
                                        go func() {
                                                state.pings <- struct{}{}
                                                state.wg.Done()
-                                               state.Ctx.LogD("HERE", SDS{}, "PING GOROUTINE QUIT")
                                        }()
                                }
                        }
@@ -768,8 +766,7 @@ func (state *SPState) StartWorkers(
                                        break
                                }
                                unmarshalErr := err.(*xdr.UnmarshalError)
-                               netErr, ok := unmarshalErr.Err.(net.Error)
-                               if ok && netErr.Timeout() {
+                               if os.IsTimeout(unmarshalErr.Err) {
                                        continue
                                }
                                if unmarshalErr.ErrorCode == xdr.ErrIO {
@@ -854,6 +851,9 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        state.Ctx.LogE("sp-process", sds, err, "")
                        return nil, err
                }
+               if head.Type != SPTypePing {
+                       state.RxLastNonPing = state.RxLastSeen
+               }
                switch head.Type {
                case SPTypeHalt:
                        state.Ctx.LogD("sp-process", SdsAdd(sds, SDS{"type": "halt"}), "")
@@ -1089,9 +1089,6 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        )
                        return nil, BadPktType
                }
-               if head.Type != SPTypePing {
-                       state.RxLastNonPing = state.RxLastSeen
-               }
        }
        if infosGot {
                var pkts int