未验证 提交 21b7ceba 编写于 作者: M Medya Ghazizadeh 提交者: GitHub

Merge pull request #8335 from sakshamkhanna/bugfix/sakshamkhanna/ssh_runner_race_condition

added mutex lock over teePrefix()
......@@ -25,6 +25,7 @@ import (
"os/exec"
"strconv"
"strings"
"sync"
"time"
"github.com/pkg/errors"
......@@ -37,6 +38,9 @@ var (
// OutPrefix notes output
OutPrefix = "> "
// Mutex protects teePrefix from writing to same log buffer parallelly
logMutex = &sync.Mutex{}
)
// RunResult holds the results of a Runner
......@@ -88,6 +92,9 @@ func (rr RunResult) Output() string {
// teePrefix copies bytes from a reader to writer, logging each new line.
func teePrefix(prefix string, r io.Reader, w io.Writer, logger func(format string, args ...interface{})) error {
logMutex.Lock()
defer logMutex.Unlock()
scanner := bufio.NewScanner(r)
scanner.Split(bufio.ScanBytes)
var line bytes.Buffer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册