Skip to content

Commit 5dddd26

Browse files
committed
quick patch for negative workers
1 parent f161907 commit 5dddd26

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

surge/SurgeCore.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ func WriteChunk(FileID string, ChunkID int32, Chunk []byte) {
264264
defer RecoverAndLog()
265265

266266
workerCount--
267+
if workerCount < 0 {
268+
workerCount = 0
269+
}
267270

268271
fileInfo, err := dbGetFile(FileID)
269272
if err != nil {

surge/download.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ func downloadChunks(file *File, randomChunks []int) {
198198
appendChunkLock.Unlock()
199199

200200
workerCount--
201+
//TODO: Remove this clamp, dont double count timeouted arrivals
202+
if workerCount < 0 {
203+
workerCount = 0
204+
}
201205

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

273277
workerCount--
278+
//TODO: Remove this clamp, dont double count timeouted arrivals
279+
if workerCount < 0 {
280+
workerCount = 0
281+
}
274282

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

0 commit comments

Comments
 (0)