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(server): avoid race conditions in Run/Stop #725

Merged
merged 1 commit into from Apr 15, 2014

Conversation

dougm
Copy link
Contributor

@dougm dougm commented Apr 15, 2014

  • don't close ready channel until PeerServer is listening.
    avoids possible panic in Stop() if PeerServer is nil.
  • avoid data race in Run() (err variable was shared between 2 goroutines)
  • avoid data race in PeerServer Start/Stop (PeerServer.closeChan)

@xiang90
Copy link
Contributor

xiang90 commented Apr 15, 2014

@dougm Thanks!
@unihorn This looks good to me. I want you to review this too and click the merge button.

@@ -72,6 +73,7 @@ type PeerServer struct {
proxyClientURL string

metrics *metrics.Bucket
mutex sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to treat it as an anonymous field here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, done.

@yichengq
Copy link
Contributor

Great work!

- don't close ready channel until PeerServer is listening.
  avoids possible panic in Stop() if PeerServer is nil.

- avoid data race in Run() (err variable was shared between 2 goroutines)

- avoid data race in PeerServer Start/Stop (PeerServer.closeChan)
@yichengq
Copy link
Contributor

lgtm

yichengq added a commit that referenced this pull request Apr 15, 2014
fix(server): avoid race conditions in Run/Stop
@yichengq yichengq merged commit 65b872c into etcd-io:master Apr 15, 2014
fanminshi added a commit to fanminshi/etcd that referenced this pull request Feb 17, 2017
etcd process won't close on SIGINT. related issue
etcd-io#725.
fanminshi added a commit to fanminshi/etcd that referenced this pull request Feb 17, 2017
etcd process won't terminateon SIGINT
but will on SIGTERM if test is run as a background process.
related issue etcd-io#725.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants