From fd37f5c24b6503dc210b1045f7fa370549795a41 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 22 Feb 2016 02:44:29 +1100 Subject: [PATCH] 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. --- fs/torrentfs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: -- 2.48.1