From: Matt Joiner Date: Sun, 21 Feb 2016 15:44:29 +0000 (+1100) Subject: fs: Fix what looks like a glaring mistake: If Seek failed on the torrent reader,... X-Git-Tag: v1.0.0~859 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=fd37f5c24b6503dc210b1045f7fa370549795a41;p=btrtrc.git fs: Fix what looks like a glaring mistake: If Seek failed on the torrent reader, it would have got stuck Since Seek is artificial, and the offsets are usually checked in the caller, it looks like it never failed anyway. --- diff --git a/fs/torrentfs.go b/fs/torrentfs.go index 06dbae55..8e3fca53 100644 --- a/fs/torrentfs.go +++ b/fs/torrentfs.go @@ -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: