Browse Source

doing a backwards loop instead

afeiszli 3 years ago
parent
commit
dbec514d5d
1 changed files with 7 additions and 6 deletions
  1. 7 6
      logic/zombie.go

+ 7 - 6
logic/zombie.go

@@ -47,12 +47,13 @@ func ManageZombies(ctx context.Context) {
 			zombies = append(zombies, id)
 			zombies = append(zombies, id)
 		case id := <-removeZombie:
 		case id := <-removeZombie:
 			found := false
 			found := false
-			for i := 0; i < len(zombies); i++ {
-				if zombies[i] == id {
-					logger.Log(1, "removing zombie from quaratine list", zombies[i])
-					zombies = append(zombies[:i], zombies[i+1:]...)
-					found = true
-					i--
+			if len(zombies) > 0 {
+				for i := len(zombies) - 1; i <= 0; i-- {
+					if zombies[i] == id {
+						logger.Log(1, "removing zombie from quaratine list", zombies[i])
+						zombies = append(zombies[:i], zombies[i+1:]...)
+						found = true
+					}
 				}
 				}
 			}
 			}
 			if !found {
 			if !found {