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.
|
||||
func (t *Torrent) Drop() {
|
||||
t.cl.lock()
|
||||
defer t.cl.unlock()
|
||||
t.cl.dropTorrent(t.infoHash)
|
||||
t.cl.unlock()
|
||||
}
|
||||
|
||||
// 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.tickleReaders()
|
||||
if t.storage != nil {
|
||||
t.storageLock.Lock()
|
||||
t.storage.Close()
|
||||
t.storageLock.Unlock()
|
||||
func() {
|
||||
t.storageLock.Lock()
|
||||
defer t.storageLock.Unlock()
|
||||
t.storage.Close()
|
||||
}()
|
||||
}
|
||||
t.iterPeers(func(p *Peer) {
|
||||
p.close()
|
||||
|
|
Loading…
Reference in New Issue