Skip to content

Commit

Permalink
quick patch for negative workers
Browse files Browse the repository at this point in the history
  • Loading branch information
MutsiMutsi committed Jan 4, 2021
1 parent f161907 commit 5dddd26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions surge/SurgeCore.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ func WriteChunk(FileID string, ChunkID int32, Chunk []byte) {
defer RecoverAndLog()

workerCount--
if workerCount < 0 {
workerCount = 0
}

fileInfo, err := dbGetFile(FileID)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions surge/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ func downloadChunks(file *File, randomChunks []int) {
appendChunkLock.Unlock()

workerCount--
//TODO: Remove this clamp, dont double count timeouted arrivals
if workerCount < 0 {
workerCount = 0
}

//This file was not available at this time from this seeder, drop seeder for file.
mutateSeederLock.Lock()
Expand Down Expand Up @@ -271,6 +275,10 @@ func downloadChunks(file *File, randomChunks []int) {
appendChunkLock.Unlock()

workerCount--
//TODO: Remove this clamp, dont double count timeouted arrivals
if workerCount < 0 {
workerCount = 0
}

//This file was not available at this time from this seeder, drop seeder for file.
mutateSeederLock.Lock()
Expand Down

0 comments on commit 5dddd26

Please sign in to comment.