From 60e950015c347d4d86e6db1d76547a706706960c Mon Sep 17 00:00:00 2001 From: zgfzgf <1901989065@qq.com> Date: Fri, 25 Sep 2020 22:13:27 +0800 Subject: [PATCH] modify for unsafe --- extern/sector-storage/sched.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/extern/sector-storage/sched.go b/extern/sector-storage/sched.go index 8b8ef6d46..89a4d6f3f 100644 --- a/extern/sector-storage/sched.go +++ b/extern/sector-storage/sched.go @@ -417,6 +417,7 @@ func (sh *scheduler) trySched() { // Step 2 scheduled := 0 + rmQueue := make([]int, 0, sh.schedQueue.Len()) for sqi := 0; sqi < sh.schedQueue.Len(); sqi++ { task := (*sh.schedQueue)[sqi] @@ -453,11 +454,16 @@ func (sh *scheduler) trySched() { windows[selectedWindow].todo = append(windows[selectedWindow].todo, task) - sh.schedQueue.Remove(sqi) - sqi-- + rmQueue = append(rmQueue, sqi) scheduled++ } + if len(rmQueue) > 0 { + for i := len(rmQueue) - 1; i >= 0; i++ { + sh.schedQueue.Remove(rmQueue[i]) + } + } + // Step 3 if scheduled == 0 {