DefaultDeadline = 10 * time.Second
PingTimeout = time.Minute
- spCheckers = make(map[NodeId]*SPCheckerQueues)
+ spCheckers = make(map[NodeId]*SPCheckerQueues)
+ SPCheckersWg sync.WaitGroup
)
type FdAndFullSize struct {
for range state.pings {
}
}()
- go func() {
- for _, s := range state.fds {
- s.fd.Close()
- }
- }()
}
func (state *SPState) NotAlive() bool {
{"Node", nodeId},
{"Pkt", pktName},
}
+ SPCheckersWg.Add(1)
ctx.LogD("sp-checker", les, func(les LEs) string {
return fmt.Sprintf("Checksumming %s/rx/%s", ctx.NodeName(nodeId), pktName)
})
pktName, humanize.IBytes(uint64(size)),
)
})
+ SPCheckersWg.Done()
go func(hsh *[32]byte) { checked <- hsh }(hshValue)
}
}
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)
state.wg.Wait()
close(state.payloads)
close(state.pings)
- state.dirUnlock()
state.Duration = time.Now().Sub(state.started)
+ SPCheckersWg.Wait()
+ state.dirUnlock()
state.RxSpeed = state.RxBytes
state.TxSpeed = state.TxBytes
rxDuration := int64(state.RxLastSeen.Sub(state.started).Seconds())
if txDuration > 0 {
state.TxSpeed = state.TxBytes / txDuration
}
+ for _, s := range state.fds {
+ s.fd.Close()
+ }
for pktName := range state.progressBars {
ProgressKill(pktName)
}