Merge pull request #113 from ooni/bug-ooni/probe#1013

Interrupt the nettestGroup loop early on termination
This commit is contained in:
Arturo Filastò 2020-02-27 14:47:52 +01:00 committed by GitHub
commit 9eaa25656c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,11 @@ import (
) )
func runNettestGroup(tg string, ctx *ooni.Context, network *database.Network) error { 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] group, ok := nettests.NettestGroups[tg]
if !ok { if !ok {
log.Errorf("No test group named %s", tg) 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() ctx.MaybeListenForStdinClosed()
for i, nt := range group.Nettests { for i, nt := range group.Nettests {
if ctx.IsTerminated() == true { if ctx.IsTerminated() == true {
log.Debugf("context is terminated, breaking") log.Debugf("context is terminated, stopping group.Nettests early")
break break
} }
log.Debugf("Running test %T", nt) log.Debugf("Running test %T", nt)