]> Sergey Matveev's repositories - btrtrc.git/blobdiff - t.go
Fix Torrent.Drop to wait for storage close without client lock
[btrtrc.git] / t.go
diff --git a/t.go b/t.go
index ebb328835deaa3cfa8f42ba7346b9d5ffcc4e4a4..153264e928d5c62823c0ff222bb65f39f82dc7be 100644 (file)
--- a/t.go
+++ b/t.go
@@ -5,6 +5,7 @@ import (
        "strings"
 
        "github.com/anacrolix/missinggo/pubsub"
+       "github.com/anacrolix/sync"
 
        "github.com/anacrolix/torrent/metainfo"
 )
@@ -95,9 +96,11 @@ func (t *Torrent) PieceBytesMissing(piece int) int64 {
 // this. No data corruption can, or should occur to either the torrent's data,
 // or connected peers.
 func (t *Torrent) Drop() {
+       var wg sync.WaitGroup
+       defer wg.Wait()
        t.cl.lock()
        defer t.cl.unlock()
-       t.cl.dropTorrent(t.infoHash)
+       t.cl.dropTorrent(t.infoHash, &wg)
 }
 
 // Number of bytes of the entire torrent we have completed. This is the sum of