Open
Description
A race condition happens when opening a client
Here's the error
==================
WARNING: DATA RACE
Write at 0x00c000136140 by goroutine 7:
github.com/james-barrow/golang-ipc.startClient()
/Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:63 +0x38
github.com/james-barrow/golang-ipc.StartClient.func1()
/Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:56 +0x34
Previous read at 0x00c000136140 by main goroutine:
github.com/james-barrow/golang-ipc.(*Client).Write()
/Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:198 +0x4c
main.startIPCClient()
/Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:18 +0x9c
main.main()
/Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:10 +0x20
Goroutine 7 (running) created at:
github.com/james-barrow/golang-ipc.StartClient()
/Users/thomas/go/pkg/mod/github.com/james-barrow/[email protected]/client_all.go:56 +0x388
main.startIPCClient()
/Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:14 +0x58
main.main()
/Users/thomas/go/src/github.com/equals215/deepsentinel/agent/test-tbd/main.go:10 +0x20
==================
Found 1 data race(s)
exit status 66
Here's the code that trigger this race condition :
package main
import (
"fmt"
ipc "github.com/james-barrow/golang-ipc"
)
func main() {
startIPCClient()
}
func startIPCClient() (*ipc.Client, error) {
c, err := ipc.StartClient("testIPC", &ipc.ClientConfig{Timeout: 500})
if err != nil {
return nil, err
}
c.Write(1, []byte("ping"))
resp, err := c.Read()
if err != nil {
return nil, err
}
if string(resp.Data) != "pong" {
return nil, fmt.Errorf("unexpected response: %s", resp.Data)
}
return c, nil
}
Metadata
Metadata
Assignees
Labels
No labels