Improve some lock handling under panics
This commit is contained in:
parent
627b75c8b4
commit
4ab20f60b6
2
t.go
2
t.go
|
@ -85,8 +85,8 @@ func (t *Torrent) PieceBytesMissing(piece int) int64 {
|
||||||
// or connected peers.
|
// or connected peers.
|
||||||
func (t *Torrent) Drop() {
|
func (t *Torrent) Drop() {
|
||||||
t.cl.lock()
|
t.cl.lock()
|
||||||
|
defer t.cl.unlock()
|
||||||
t.cl.dropTorrent(t.infoHash)
|
t.cl.dropTorrent(t.infoHash)
|
||||||
t.cl.unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number of bytes of the entire torrent we have completed. This is the sum of
|
// Number of bytes of the entire torrent we have completed. This is the sum of
|
||||||
|
|
|
@ -741,9 +741,11 @@ func (t *Torrent) close() (err error) {
|
||||||
t.closed.Set()
|
t.closed.Set()
|
||||||
t.tickleReaders()
|
t.tickleReaders()
|
||||||
if t.storage != nil {
|
if t.storage != nil {
|
||||||
t.storageLock.Lock()
|
func() {
|
||||||
t.storage.Close()
|
t.storageLock.Lock()
|
||||||
t.storageLock.Unlock()
|
defer t.storageLock.Unlock()
|
||||||
|
t.storage.Close()
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
t.iterPeers(func(p *Peer) {
|
t.iterPeers(func(p *Peer) {
|
||||||
p.close()
|
p.close()
|
||||||
|
|
Loading…
Reference in New Issue