-
Notifications
You must be signed in to change notification settings - Fork 8
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 concurrency issues and data race on tests #53
Conversation
extensions/apns_message_handler.go
Outdated
@@ -411,7 +415,7 @@ func (a *APNSMessageHandler) LogStats() { | |||
func (a *APNSMessageHandler) mapErrorReason(reason string) string { | |||
switch reason { | |||
case apns2.ReasonPayloadEmpty: | |||
return "payload-empty" |
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.
Was it intentional?
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. Fixed.
extensions/apns_message_handler.go
Outdated
@@ -411,7 +415,7 @@ func (a *APNSMessageHandler) LogStats() { | |||
func (a *APNSMessageHandler) mapErrorReason(reason string) string { | |||
switch reason { | |||
case apns2.ReasonPayloadEmpty: | |||
return "payload-empty" |
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.
why are we changing this?
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.
It was not intentional
} | ||
|
||
//func (s *GCMMessageHandlerTestSuite) SetupSubTest() { |
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.
Do we still need this? Can't we just remove?
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.
Removed
s.Equal(int64(1), handler.sentMessages) | ||
s.Equal(int64(0), handler.ignoredMessages) |
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.
Don't we need to acquire/release lock here?
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
feedback/invalid_token.go
Outdated
|
||
i.BufferLock.Lock() |
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.
Why we don't use the same .Lock()
+ .Unlock
block for appending and clearing the buffer? Is i.deleteTokens
a costly operation?
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 actual reason. Set everything to one lock/unlock.
feedback/invalid_token.go
Outdated
if len(i.Buffer) >= i.bufferSize { | ||
l.Debug("buffer is full") | ||
i.deleteTokens(i.Buffer) | ||
i.Buffer = make([]*InvalidToken, 0, i.bufferSize) | ||
} | ||
i.BufferLock.Unlock() | ||
} | ||
|
||
case <-flushTicker.C: | ||
l.Debug("flush ticker") | ||
i.deleteTokens(i.Buffer) |
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.
shouldn't we guard deleteTokens
under the .Lock()
since we're changing i.Buffer
?
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 catch!
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.
LGTM, just fix the tests before merging :)
No description provided.