}
// Called when metadata for a torrent becomes available.
-func (t *Torrent) setInfoBytes(b []byte) error {
+func (t *Torrent) setInfoBytesLocked(b []byte) error {
if metainfo.HashBytes(b) != t.infoHash {
return errors.New("info bytes have wrong hash")
}
// Don't have enough metadata pieces.
return nil
}
- err := t.setInfoBytes(t.metadataBytes)
+ err := t.setInfoBytesLocked(t.metadataBytes)
if err != nil {
t.invalidateMetadata()
return fmt.Errorf("error setting info bytes: %s", err)
func (t *Torrent) SetInfoBytes(b []byte) (err error) {
t.cl.lock()
defer t.cl.unlock()
- return t.setInfoBytes(b)
+ return t.setInfoBytesLocked(b)
}
// Returns true if connection is removed from torrent.Conns.
return
}
-func (t *Torrent) announceToDht(s DhtServer) error {
+func (t *Torrent) timeboxedAnnounceToDht(s DhtServer) error {
_, stop, err := t.AnnounceToDht(s)
if err != nil {
return err
t.numDHTAnnounces++
cl.unlock()
defer cl.lock()
- err := t.announceToDht(s)
+ err := t.timeboxedAnnounceToDht(s)
if err != nil {
t.logger.WithDefaultLevel(log.Warning).Printf("error announcing %q to DHT: %s", t, err)
}