-
Notifications
You must be signed in to change notification settings - Fork 514
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 panic when a signal is delivered before the server is instantiated #580
Conversation
…server before assigning it (ie. read before write) fixes elastic#514
CHANGELOG.asciidoc
Outdated
@@ -20,7 +20,8 @@ https://github.com/elastic/apm-server/compare/71df0d96445df35afe27f38bcf734a0828 | |||
==== Bug fixes | |||
- Updated systemd doc url {pull}354[354] | |||
- Updated readme doc urls {pull}356[356] | |||
- Use updated stack trace frame values for calculating error `grouping_keys` {pull}485[485] | |||
- Use updated stack trace frame values for calculating error `grouping_keys` {pull}485[485] | |||
- Fix panic when a SIGINT is delivered before the server is instantiated {pull}580[580] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of a nitpick but we currently catch INT
and TERM
, maybe just signal
instead?
beater/beater.go
Outdated
@@ -7,14 +7,18 @@ import ( | |||
"net/http" | |||
"regexp" | |||
|
|||
"sync" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how this is getting through the make check
- can you group this with the other stdlib imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always have this problem, this is how it looks after running gofmt
and goimports
. Eventually got tired of fixing white lines in import blocks manually... it might be because of my IDE, but make check
seems to be happy with this indeed.
beater/beater.go
Outdated
server *http.Server | ||
config *Config | ||
server *http.Server | ||
mutex sync.RWMutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mutex
is guarding both server
and stopped
- can you move it above and add a comment to that effect like here?
@@ -36,7 +40,8 @@ func New(b *beat.Beat, ucfg *common.Config) (beat.Beater, error) { | |||
} | |||
|
|||
bt := &beater{ | |||
config: beaterConfig, | |||
config: beaterConfig, | |||
stopped: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this being explicit 👍
thanks Gil, comments addressed here 0731cbe |
beater/beater.go
Outdated
config *Config | ||
server *http.Server | ||
config *Config | ||
mutex sync.RWMutex // guards server and stopped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for a RWMutex if RLock
and RUnlock
isn't used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, good point
elastic#580) Introduce a flag and a mutex in the beater so that we can't stop the server before assigning it (ie. read before write) fixes elastic#514
elastic#580) Introduce a flag and a mutex in the beater so that we can't stop the server before assigning it (ie. read before write) fixes elastic#514
elastic#580) Introduce a flag and a mutex in the beater so that we can't stop the server before assigning it (ie. read before write) fixes elastic#514
elastic#580) Introduce a flag and a mutex in the beater so that we can't stop the server before assigning it (ie. read before write) fixes elastic#514
Introduce a flag and a mutex in the beater so that we can't stop the server before assigning it (ie. read before write)
fixes #514