Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data race #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

noahlevenson
Copy link

When importing github.com/enobufs/go-nats/nats as a library and compiling my program with the -race flag, I consistently received the following data race warning:

==================                                                             
WARNING: DATA RACE                                                                                                                                             
Write at 0x00c0001cf4c0 by goroutine 421:  
  github.com/enobufs/go-nats/nats.(*NATS).performTransactionWith.func1()
      /home/noah/go/pkg/mod/github.com/enobufs/[email protected]/nats/discover.go:329 +0x230
                                                                               
Previous write at 0x00c0001cf4c0 by goroutine 422:
  github.com/enobufs/go-nats/nats.(*NATS).performTransactionWith.func1()
      /home/noah/go/pkg/mod/github.com/enobufs/[email protected]/nats/discover.go:335 +0x357
                                                                                                                                                               
Goroutine 421 (running) created at:                                            
  github.com/enobufs/go-nats/nats.(*NATS).performTransactionWith()       
      /home/noah/go/pkg/mod/github.com/enobufs/[email protected]/nats/discover.go:318 +0x28c
  github.com/enobufs/go-nats/nats.(*NATS).discoverFilteringBehavior.func1() 
      /home/noah/go/pkg/mod/github.com/enobufs/[email protected]/nats/discover.go:266 +0x139
                                                                               
Goroutine 422 (running) created at:                                            
  github.com/enobufs/go-nats/nats.(*NATS).performTransactionWith()
      /home/noah/go/pkg/mod/github.com/enobufs/[email protected]/nats/discover.go:318 +0x28c
  github.com/enobufs/go-nats/nats.(*NATS).discoverFilteringBehavior.func1()
      /home/noah/go/pkg/mod/github.com/enobufs/[email protected]/nats/discover.go:271 +0x16c
==================

Putting a lock on NATS.dfErr makes it go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant