mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
remove reader mutex for test
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package torrstor
|
package torrstor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sync "github.com/sasha-s/go-deadlock"
|
|
||||||
"io"
|
"io"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent"
|
"github.com/anacrolix/torrent"
|
||||||
"server/log"
|
"server/log"
|
||||||
@@ -16,7 +16,7 @@ type Reader struct {
|
|||||||
|
|
||||||
cache *Cache
|
cache *Cache
|
||||||
isClosed bool
|
isClosed bool
|
||||||
mu sync.Mutex
|
// mu sync.Mutex
|
||||||
|
|
||||||
///Preload
|
///Preload
|
||||||
muPreload sync.Mutex
|
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) {
|
func (r *Reader) Seek(offset int64, whence int) (n int64, err error) {
|
||||||
r.mu.Lock()
|
// r.mu.Lock()
|
||||||
defer r.mu.Unlock()
|
// defer r.mu.Unlock()
|
||||||
if r.isClosed {
|
if r.isClosed {
|
||||||
return 0, io.EOF
|
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) {
|
func (r *Reader) Read(p []byte) (n int, err error) {
|
||||||
r.mu.Lock()
|
|
||||||
defer r.mu.Unlock()
|
|
||||||
err = io.EOF
|
err = io.EOF
|
||||||
if r.isClosed {
|
if r.isClosed {
|
||||||
return
|
return
|
||||||
@@ -73,8 +71,8 @@ func (r *Reader) Read(p []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) SetReadahead(length int64) {
|
func (r *Reader) SetReadahead(length int64) {
|
||||||
r.mu.Lock()
|
// r.mu.Lock()
|
||||||
defer r.mu.Unlock()
|
// defer r.mu.Unlock()
|
||||||
r.Reader.SetReadahead(length)
|
r.Reader.SetReadahead(length)
|
||||||
r.readahead = length
|
r.readahead = length
|
||||||
}
|
}
|
||||||
@@ -91,12 +89,12 @@ func (r *Reader) Close() {
|
|||||||
// file reader close in gotorrent
|
// file reader close in gotorrent
|
||||||
// this struct close in cache
|
// this struct close in cache
|
||||||
// TODO провверить как будут закрываться ридеры
|
// TODO провверить как будут закрываться ридеры
|
||||||
r.mu.Lock()
|
// r.mu.Lock()
|
||||||
r.isClosed = true
|
r.isClosed = true
|
||||||
if len(r.file.Torrent().Files()) > 0 {
|
if len(r.file.Torrent().Files()) > 0 {
|
||||||
r.Reader.Close()
|
r.Reader.Close()
|
||||||
}
|
}
|
||||||
r.mu.Unlock()
|
// r.mu.Unlock()
|
||||||
go r.cache.getRemPieces()
|
go r.cache.getRemPieces()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user