Skip to content

Commit

Permalink
Fix a data race between Cmd.Run and Process.Kill (#31)
Browse files Browse the repository at this point in the history
* Fix a data race between Cmd.Run and Process.Kill

* Travis: test with race detection enabled
  • Loading branch information
IngmarStein authored and ddelnano committed Jun 22, 2017
1 parent f0b023e commit 3b65f3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
install:
- go get -u github.com/kardianos/govendor
- go install github.com/kardianos/govendor
- go build -o $GOPATH/bin/goodman github.com/snikch/goodman/cmd/goodman
- go build -race -o $GOPATH/bin/goodman github.com/snikch/goodman/cmd/goodman
- cd example && $GOPATH/bin/govendor sync && cd ..

go_import_path: github.com/snikch/goodman
Expand Down
12 changes: 7 additions & 5 deletions cmd/goodman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {
closeHooksServers()
os.Exit(0)
}()
hooksServerCount = len(args) - 1
hooksServerCount = len(hookPaths)
if len(args) < 2 {
runners = append(runners, &goodman.DummyRunner{})
} else {
Expand All @@ -45,11 +45,13 @@ func main() {
fmt.Println("Sending to channel\n")
cmds <- cmd
fmt.Println("Completed")
log.Printf("Starting hooks server")
if err := cmd.Start(); err != nil {
panic("Failed to start hooks server " + err.Error())
}
go func() {
log.Printf("Starting hooks server in go routine")
err := cmd.Run()
if err != nil {
fmt.Println("Hooks client failed with " + err.Error())
if err := cmd.Wait(); err != nil {
fmt.Println("Hooks server failed with " + err.Error())
}
}()
rpcService := reflect.TypeOf((*hooks.HooksRunner)(nil)).Elem().Name()
Expand Down

0 comments on commit 3b65f3e

Please sign in to comment.