lib/connections: Fix race condition in parallel dial, minor cleanups (fixes #4526)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4527
This commit is contained in:
committed by
Audrius Butkevicius
parent
9471b9f6af
commit
72d645865e
@@ -746,13 +746,13 @@ func dialParallel(deviceID protocol.DeviceID, dialTargets []dialTarget) (interna
|
||||
wg := sync.NewWaitGroup()
|
||||
for _, tgt := range tgts {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
go func(tgt dialTarget) {
|
||||
conn, err := tgt.Dial()
|
||||
if err == nil {
|
||||
res <- conn
|
||||
}
|
||||
wg.Done()
|
||||
}()
|
||||
}(tgt)
|
||||
}
|
||||
|
||||
// Spawn a routine which will unblock main routine in case we fail
|
||||
|
||||
Reference in New Issue
Block a user