dht: Fix race contacting starting addrs in Announce

This commit is contained in:
Matt Joiner 2016-05-07 19:02:30 +10:00
parent 1d87653738
commit b9a7cbfa14
1 changed files with 4 additions and 2 deletions

View File

@ -96,13 +96,15 @@ func (s *Server) Announce(infoHash string, port int, impliedPort bool) (*Announc
}
}()
go func() {
disc.mu.Lock()
defer disc.mu.Unlock()
for i, addr := range startAddrs {
if i != 0 {
time.Sleep(time.Millisecond)
}
disc.mu.Lock()
disc.contact(addr)
disc.mu.Unlock()
time.Sleep(time.Millisecond)
disc.mu.Lock()
}
disc.contact(addr)
}
disc.contactedStartAddrs = true
// If we failed to contact any of the starting addrs, no transactions