From: Sergey Matveev Date: Sun, 30 May 2021 16:01:05 +0000 (+0300) Subject: Debug friendly if conditions X-Git-Tag: v6.5.0^2~1 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=429356eac19435f44e48ad24a00ce7564c95692f;p=nncp.git Debug friendly if conditions --- diff --git a/src/sp.go b/src/sp.go index d7e4882..2dde928 100644 --- a/src/sp.go +++ b/src/sp.go @@ -795,13 +795,20 @@ func (state *SPState) StartWorkers( pingTicker.Stop() return case now := <-deadlineTicker.C: - if (now.Sub(state.RxLastNonPing) >= state.onlineDeadline && - now.Sub(state.TxLastNonPing) >= state.onlineDeadline) || - (state.maxOnlineTime > 0 && state.mustFinishAt.Before(now)) || - (now.Sub(state.RxLastSeen) >= 2*PingTimeout) { - state.SetDead() - conn.Close() // #nosec G104 + if now.Sub(state.RxLastNonPing) >= state.onlineDeadline && + now.Sub(state.TxLastNonPing) >= state.onlineDeadline { + goto Deadlined } + if state.maxOnlineTime > 0 && state.mustFinishAt.Before(now) { + goto Deadlined + } + if now.Sub(state.RxLastSeen) >= 2*PingTimeout { + goto Deadlined + } + break + Deadlined: + state.SetDead() + conn.Close() // #nosec G104 case now := <-pingTicker.C: if now.After(state.TxLastSeen.Add(PingTimeout)) { state.wg.Add(1)