t.go | 2 +- torrent.go | 8 +++++--- diff --git a/t.go b/t.go index a0b5cb59a55070eb4fdbae394640e2b318ceed3e..a3be2d266c3cff9a2922746edfa3a3765e43917b 100644 --- a/t.go +++ b/t.go @@ -85,8 +85,8 @@ // this. No data corruption can, or should occur to either the torrent's data, // 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 diff --git a/torrent.go b/torrent.go index 52fff16a15ecff935d43b853898665a86503d6e9..32b7e5fda1a74e67b0fa24c8f304d6e9541e7aad 100644 --- a/torrent.go +++ b/torrent.go @@ -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()