From 5cfb34a151518f0919a3da000a4c78c0d3dd3564 Mon Sep 17 00:00:00 2001 From: Lewis Marshall Date: Sun, 18 Jun 2017 12:13:49 +0200 Subject: [PATCH] p2p/simulations: Fix stopping exec nodes Signed-off-by: Lewis Marshall --- p2p/simulations/adapters/exec.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/p2p/simulations/adapters/exec.go b/p2p/simulations/adapters/exec.go index 319e4353a2..81267e097b 100644 --- a/p2p/simulations/adapters/exec.go +++ b/p2p/simulations/adapters/exec.go @@ -183,25 +183,18 @@ func (n *ExecNode) Start(snapshots map[string][]byte) (err error) { // read the WebSocket address from the stderr logs var wsAddr string - errC := make(chan error) + wsAddrC := make(chan string) go func() { s := bufio.NewScanner(stderrR) for s.Scan() { if strings.Contains(s.Text(), "WebSocket endpoint opened:") { - wsAddr = wsAddrPattern.FindString(s.Text()) - break + wsAddrC <- wsAddrPattern.FindString(s.Text()) } } - select { - case errC <- s.Err(): - default: - } }() select { - case err := <-errC: - if err != nil { - return fmt.Errorf("error reading WebSocket address from stderr: %s", err) - } else if wsAddr == "" { + case wsAddr = <-wsAddrC: + if wsAddr == "" { return errors.New("failed to read WebSocket address from stderr") } case <-time.After(10 * time.Second):