Skip to content

Commit

Permalink
Removed sshCommandStream from goroutine as it was bypassing workers a…
Browse files Browse the repository at this point in the history
…nd running against all hosts simultaneously.
  • Loading branch information
DiscoRiver committed Jun 28, 2022
1 parent 4b7f1bb commit ed8773e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions _examples/streaming/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func main() {
cfg := massh.NewConfig()
cfg.SSHConfig = sshc
cfg.Job = j
cfg.WorkerPool = 10
cfg.WorkerPool = 1
cfg.SetHosts([]string{"192.168.1.118", "192.168.1.119", "192.168.1.120", "192.168.1.129", "192.168.1.212"})

resChan := make(chan massh.Result)
resChan := make(chan *massh.Result)

// This should be the last responsibility from the massh package. Handling the Result channel is up to the user.
err := cfg.Stream(resChan)
Expand Down Expand Up @@ -70,7 +70,7 @@ func main() {
}

// Read Stdout stream
func readStream(res massh.Result, wg *sync.WaitGroup) error {
func readStream(res *massh.Result, wg *sync.WaitGroup) error {
for {
select {
case d := <-res.StdOutStream:
Expand Down
4 changes: 2 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ func worker(hosts <-chan string, results chan<- Result, config *Config, resChan
j := (*config.JobStack)[i]
cfg.Job = &j

go sshCommandStream(host, cfg, resChan)
sshCommandStream(host, cfg, resChan)
}
} else {
go sshCommandStream(host, config, resChan)
sshCommandStream(host, config, resChan)
}
}
}
Expand Down

0 comments on commit ed8773e

Please sign in to comment.