service: plumb contexts to all (most) threads (#7363)

This continues the push of plumbing contexts through tendermint. I
attempted to find all goroutines in the production code (non-test) and
made sure that these threads would exit when their contexts were
canceled, and I believe this PR does that.
This commit is contained in:
Sam Kleinman
2021-12-02 16:38:38 -05:00
committed by GitHub
parent b3be1d7d7a
commit 8a991e288c
64 changed files with 964 additions and 727 deletions

View File

@@ -69,7 +69,10 @@ func RunCaptureWithArgs(cmd Executable, args []string, env map[string]string) (s
var buf bytes.Buffer
// io.Copy will end when we call reader.Close() below
io.Copy(&buf, reader) //nolint:errcheck //ignore error
stdC <- buf.String()
select {
case <-cmd.Context().Done():
case stdC <- buf.String():
}
}()
return &stdC
}

View File

@@ -1,6 +1,7 @@
package cli
import (
"context"
"fmt"
"os"
"path/filepath"
@@ -22,6 +23,7 @@ const (
// wrap if desired before the test
type Executable interface {
Execute() error
Context() context.Context
}
// PrepareBaseCmd is meant for tendermint and other servers