// Get missing bytes count for specific piece.
func (t *Torrent) PieceBytesMissing(piece int) int64 {
- t.cl.lock()
- defer t.cl.unlock()
+ t.cl.rLock()
+ defer t.cl.rUnlock()
return int64(t.pieces[piece].bytesLeft())
}
defer wg.Wait()
t.cl.lock()
defer t.cl.unlock()
- t.cl.dropTorrent(t.infoHash, &wg)
+ err := t.cl.dropTorrent(t.infoHash, &wg)
+ if err != nil {
+ panic(err)
+ }
}
// Number of bytes of the entire torrent we have completed. This is the sum of
// Returns true if the torrent is currently being seeded. This occurs when the
// client is willing to upload without wanting anything in return.
func (t *Torrent) Seeding() (ret bool) {
- t.cl.lock()
+ t.cl.rLock()
ret = t.seeding()
- t.cl.unlock()
+ t.cl.rUnlock()
return
}
// Returns a run-time generated metainfo for the torrent that includes the
// info bytes and announce-list as currently known to the client.
func (t *Torrent) Metainfo() metainfo.MetaInfo {
- t.cl.lock()
- defer t.cl.unlock()
+ t.cl.rLock()
+ defer t.cl.rUnlock()
return t.newMetaInfo()
}
func (t *Torrent) AddPeers(pp []PeerInfo) (n int) {
t.cl.lock()
+ defer t.cl.unlock()
n = t.addPeers(pp)
- t.cl.unlock()
return
}