Interrupt the nettestGroup loop early on termination

Fixes ooni/probe#1013
This commit is contained in:
Arturo Filastò 2020-02-20 12:24:24 +01:00
parent c38c01f974
commit 35016a183e

View File

@ -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)