]> Sergey Matveev's repositories - btrtrc.git/commitdiff
fs: Fix what looks like a glaring mistake: If Seek failed on the torrent reader,...
authorMatt Joiner <anacrolix@gmail.com>
Sun, 21 Feb 2016 15:44:29 +0000 (02:44 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 21 Feb 2016 15:44:29 +0000 (02:44 +1100)
Since Seek is artificial, and the offsets are usually checked in the caller, it looks like it never failed anyway.

fs/torrentfs.go

index 06dbae558815c7051ec6206db52d68560ff98004..8e3fca536d30893e69004682ec072248ebf65836 100644 (file)
@@ -81,6 +81,7 @@ func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int
        )
        readDone := make(chan struct{})
        go func() {
+               defer close(readDone)
                r := t.NewReader()
                defer r.Close()
                _, _err = r.Seek(off, os.SEEK_SET)
@@ -88,7 +89,6 @@ func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int
                        return
                }
                _n, _err = io.ReadFull(r, p)
-               close(readDone)
        }()
        select {
        case <-readDone: