From ac4efa8a8646aa3f6d654b343d73ab0506183250 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 30 Dec 2020 10:18:17 +0300 Subject: [PATCH] remove reader mutex for test --- src/server/torr/storage/torrstor/reader.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/server/torr/storage/torrstor/reader.go b/src/server/torr/storage/torrstor/reader.go index 5219859..2c58c21 100644 --- a/src/server/torr/storage/torrstor/reader.go +++ b/src/server/torr/storage/torrstor/reader.go @@ -1,8 +1,8 @@ package torrstor import ( - sync "github.com/sasha-s/go-deadlock" "io" + "sync" "github.com/anacrolix/torrent" "server/log" @@ -16,7 +16,7 @@ type Reader struct { cache *Cache isClosed bool - mu sync.Mutex + // mu sync.Mutex ///Preload muPreload sync.Mutex @@ -37,8 +37,8 @@ func newReader(file *torrent.File, cache *Cache) *Reader { } func (r *Reader) Seek(offset int64, whence int) (n int64, err error) { - r.mu.Lock() - defer r.mu.Unlock() + // r.mu.Lock() + // defer r.mu.Unlock() if r.isClosed { return 0, io.EOF } @@ -56,8 +56,6 @@ func (r *Reader) Seek(offset int64, whence int) (n int64, err error) { } func (r *Reader) Read(p []byte) (n int, err error) { - r.mu.Lock() - defer r.mu.Unlock() err = io.EOF if r.isClosed { return @@ -73,8 +71,8 @@ func (r *Reader) Read(p []byte) (n int, err error) { } func (r *Reader) SetReadahead(length int64) { - r.mu.Lock() - defer r.mu.Unlock() + // r.mu.Lock() + // defer r.mu.Unlock() r.Reader.SetReadahead(length) r.readahead = length } @@ -91,12 +89,12 @@ func (r *Reader) Close() { // file reader close in gotorrent // this struct close in cache // TODO провверить как будут закрываться ридеры - r.mu.Lock() + // r.mu.Lock() r.isClosed = true if len(r.file.Torrent().Files()) > 0 { r.Reader.Close() } - r.mu.Unlock() + // r.mu.Unlock() go r.cache.getRemPieces() }