DefaultDeadline = 10 * time.Second
PingTimeout = time.Minute
- spWorkersGroup sync.WaitGroup
+ spCheckerToken chan struct{}
)
type SPType uint8
panic(err)
}
SPFileOverhead = buf.Len()
+ spCheckerToken = make(chan struct{}, 1)
+ spCheckerToken <- struct{}{}
}
func MarshalSP(typ SPType, sp interface{}) []byte {
fd.Close() // #nosec G104
continue
}
- spWorkersGroup.Wait()
- spWorkersGroup.Add(1)
+ <-spCheckerToken
go func() {
+ defer func() {
+ spCheckerToken <- struct{}{}
+ }()
if err := fd.Sync(); err != nil {
state.Ctx.LogE("sp-file", sdsp, err, "sync")
fd.Close() // #nosec G104
state.Lock()
delete(state.infosTheir, *file.Hash)
state.Unlock()
- spWorkersGroup.Done()
state.wg.Add(1)
go func() {
state.payloads <- MarshalSP(SPTypeDone, SPDone{file.Hash})