chore: build with Go 1.26; use Go 1.25 features (#10570)
WaitGroup.Go and built-in gomaxprocs handling. Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -256,36 +256,28 @@ func (f *sendReceiveFolder) pullerIteration(ctx context.Context, scanChan chan<-
|
||||
|
||||
f.sl.DebugContext(ctx, "Starting puller iteration", "copiers", f.Copiers, "pullerPendingKiB", f.PullerMaxPendingKiB)
|
||||
|
||||
updateWg.Add(1)
|
||||
var changed int // only read after updateWg closes
|
||||
go func() {
|
||||
updateWg.Go(func() {
|
||||
// dbUpdaterRoutine finishes when dbUpdateChan is closed
|
||||
changed = f.dbUpdaterRoutine(dbUpdateChan)
|
||||
updateWg.Done()
|
||||
}()
|
||||
})
|
||||
|
||||
for range f.Copiers {
|
||||
copyWg.Add(1)
|
||||
go func() {
|
||||
copyWg.Go(func() {
|
||||
// copierRoutine finishes when copyChan is closed
|
||||
f.copierRoutine(ctx, copyChan, pullChan, finisherChan)
|
||||
copyWg.Done()
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
pullWg.Add(1)
|
||||
go func() {
|
||||
pullWg.Go(func() {
|
||||
// pullerRoutine finishes when pullChan is closed
|
||||
f.pullerRoutine(ctx, pullChan, finisherChan)
|
||||
pullWg.Done()
|
||||
}()
|
||||
})
|
||||
|
||||
doneWg.Add(1)
|
||||
// finisherRoutine finishes when finisherChan is closed
|
||||
go func() {
|
||||
doneWg.Go(func() {
|
||||
f.finisherRoutine(ctx, finisherChan, dbUpdateChan, scanChan)
|
||||
doneWg.Done()
|
||||
}()
|
||||
})
|
||||
|
||||
fileDeletions, dirDeletions, err := f.processNeeded(ctx, dbUpdateChan, copyChan, scanChan)
|
||||
|
||||
@@ -1534,14 +1526,10 @@ func (f *sendReceiveFolder) pullerRoutine(ctx context.Context, in <-chan pullBlo
|
||||
continue
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
defer requestLimiter.Give(bytes)
|
||||
|
||||
f.pullBlock(ctx, state, out)
|
||||
}()
|
||||
})
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -463,11 +463,9 @@ func TestDeregisterOnFailInPull(t *testing.T) {
|
||||
|
||||
copyChan, copyWg := startCopier(t.Context(), f, pullChan, finisherBufferChan)
|
||||
var pullWg sync.WaitGroup
|
||||
pullWg.Add(1)
|
||||
go func() {
|
||||
pullWg.Go(func() {
|
||||
f.pullerRoutine(t.Context(), pullChan, finisherBufferChan)
|
||||
pullWg.Done()
|
||||
}()
|
||||
})
|
||||
go f.finisherRoutine(t.Context(), finisherChan, dbUpdateChan, make(chan string))
|
||||
defer func() {
|
||||
// Unblock copier and puller
|
||||
@@ -1246,10 +1244,8 @@ func cleanupSharedPullerState(s *sharedPullerState) {
|
||||
func startCopier(ctx context.Context, f *sendReceiveFolder, pullChan chan<- pullBlockState, finisherChan chan<- *sharedPullerState) (chan copyBlocksState, *sync.WaitGroup) {
|
||||
copyChan := make(chan copyBlocksState)
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Go(func() {
|
||||
f.copierRoutine(ctx, copyChan, pullChan, finisherChan)
|
||||
wg.Done()
|
||||
}()
|
||||
})
|
||||
return copyChan, wg
|
||||
}
|
||||
|
||||
@@ -993,15 +993,13 @@ func TestIssue5063(t *testing.T) {
|
||||
if fcfg, ok := m.cfg.Folder(id); !ok || !fcfg.SharedWith(device1) {
|
||||
t.Error("expected shared", id)
|
||||
}
|
||||
wg.Done()
|
||||
}
|
||||
|
||||
reps := 10
|
||||
ids := make([]string, reps)
|
||||
for i := 0; i < reps; i++ {
|
||||
wg.Add(1)
|
||||
ids[i] = srand.String(8)
|
||||
go addAndVerify(ids[i])
|
||||
wg.Go(func() { addAndVerify(ids[i]) })
|
||||
}
|
||||
|
||||
finished := make(chan struct{})
|
||||
@@ -2945,16 +2943,14 @@ func TestFolderRestartZombies(t *testing.T) {
|
||||
// for the commit to complete, but there are many of them.
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 25; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
wg.Go(func() {
|
||||
t0 := time.Now()
|
||||
for time.Since(t0) < time.Second {
|
||||
fcfg := folderCfg.Copy()
|
||||
fcfg.MaxConflicts = mrand.Int() // safe change that should cause a folder restart
|
||||
setFolder(t, wrapper, fcfg)
|
||||
}
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
// Wait for the above to complete and check how many folders we have
|
||||
|
||||
Reference in New Issue
Block a user