From 35016a183ef95c79cac68b469d79f484da1bbdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Thu, 20 Feb 2020 12:24:24 +0100 Subject: [PATCH] Interrupt the nettestGroup loop early on termination Fixes ooni/probe#1013 --- internal/cli/run/run.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/cli/run/run.go b/internal/cli/run/run.go index bfeafd5..f64f136 100644 --- a/internal/cli/run/run.go +++ b/internal/cli/run/run.go @@ -14,6 +14,11 @@ import ( ) func runNettestGroup(tg string, ctx *ooni.Context, network *database.Network) error { + if ctx.IsTerminated() == true { + log.Debugf("context is terminated, stopping runNettestGroup early") + return nil + } + group, ok := nettests.NettestGroups[tg] if !ok { log.Errorf("No test group named %s", tg) @@ -31,7 +36,7 @@ func runNettestGroup(tg string, ctx *ooni.Context, network *database.Network) er ctx.MaybeListenForStdinClosed() for i, nt := range group.Nettests { if ctx.IsTerminated() == true { - log.Debugf("context is terminated, breaking") + log.Debugf("context is terminated, stopping group.Nettests early") break } log.Debugf("Running test %T", nt)