zenhotels/astranet

Data races

Matthias247 opened this issue · 1 comments

Hi,
just wanted to try out your library and out of curiosity (threading issues are unfortunatly too common in networking applications) I compiled some examples with Gos helpful race detector enabled:
go build -race.

If I e.g. start the loopback example with it I get this output:

$ ./loopback.exe
==================
WARNING: DATA RACE
Write at 0x00c04211a150 by goroutine 19:
  github.com/zenhotels/astranet.(*multiplexer).attachNonBlock.func1()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:547 +0x432
  github.com/zenhotels/astranet/transport.(*transport).IOLoopReader()
      c:/Code/gopath/src/github.com/zenhotels/astranet/transport/upstream.go:439 +0x136a

Previous read at 0x00c04211a150 by goroutine 7:
  github.com/zenhotels/astranet.(*multiplexer).attachNonBlock()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:567 +0x53b
  github.com/zenhotels/astranet.(*multiplexer).attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:519 +0x53
  github.com/zenhotels/astranet.(*multiplexer).Attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:601 +0x61

Goroutine 19 (running) created at:
  github.com/zenhotels/astranet/transport.(*transport).init()
      c:/Code/gopath/src/github.com/zenhotels/astranet/transport/upstream.go:74 +0x4f9
  github.com/zenhotels/astranet/transport.Upstream()
      c:/Code/gopath/src/github.com/zenhotels/astranet/transport/upstream.go:475 +0x6af
  github.com/zenhotels/astranet.(*multiplexer).attachNonBlock()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:557 +0x31a
  github.com/zenhotels/astranet.(*multiplexer).attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:519 +0x53
  github.com/zenhotels/astranet.(*multiplexer).Attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:601 +0x61

Goroutine 7 (running) created at:
  main.main()
      c:/Code/gopath/src/github.com/zenhotels/astranet/example/loopback/main.go:22 +0x6a2
==================
==================
WARNING: DATA RACE
Write at 0x00c0421380d0 by goroutine 22:
  github.com/zenhotels/astranet.(*multiplexer).attachNonBlock.func1()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:547 +0x432
  github.com/zenhotels/astranet/transport.(*transport).IOLoopReader()
      c:/Code/gopath/src/github.com/zenhotels/astranet/transport/upstream.go:439 +0x136a

Previous read at 0x00c0421380d0 by goroutine 8:
  github.com/zenhotels/astranet.(*multiplexer).attachNonBlock()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:567 +0x53b
  github.com/zenhotels/astranet.(*multiplexer).attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:519 +0x53
  github.com/zenhotels/astranet.(*multiplexer).Attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:601 +0x61

Goroutine 22 (running) created at:
  github.com/zenhotels/astranet/transport.(*transport).init()
      c:/Code/gopath/src/github.com/zenhotels/astranet/transport/upstream.go:74 +0x4f9
  github.com/zenhotels/astranet/transport.Upstream()
      c:/Code/gopath/src/github.com/zenhotels/astranet/transport/upstream.go:475 +0x6af
  github.com/zenhotels/astranet.(*multiplexer).attachNonBlock()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:557 +0x31a
  github.com/zenhotels/astranet.(*multiplexer).attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:519 +0x53
  github.com/zenhotels/astranet.(*multiplexer).Attach()
      c:/Code/gopath/src/github.com/zenhotels/astranet/multiplexer_core.go:601 +0x61

Goroutine 8 (running) created at:
  main.main()
      c:/Code/gopath/src/github.com/zenhotels/astranet/example/loopback/main.go:23 +0x74e
==================
2016/09/21 22:04:19 Server says: Hello! Time: 10:04PM
Found 2 data race(s)

Hi,
Thank you for reporting this issue.
I used to perform go build -race checks later. Looks like the results of those checks expired.
I'll fix this.