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: synchronize when resetting the keepalive timer #21

Merged
merged 5 commits into from
Mar 16, 2020

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Mar 15, 2020

fixes #20

Also, fix the tests, test in CI 5 times and one more time with the race detector.

Copy link
Contributor

@willscott willscott left a comment

Choose a reason for hiding this comment

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

yay for CI working

func (s *Session) extendKeepalive() {
s.keepaliveLock.Lock()
if s.keepaliveTimer != nil && !s.keepaliveActive {
s.keepaliveTimer.Reset(s.config.KeepAliveInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

"Reset should be invoked only on stopped or expired timers with drained channels." - do we know that's the case here?

Copy link
Contributor

Choose a reason for hiding this comment

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

already discussed in the previous pr...

Copy link
Member Author

Choose a reason for hiding this comment

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

That's just bad documentation (#16 (comment)). Reset will actually call stop internally. The only reason you need to do it is if you need to drain the channel.

However, we're not even using a normal timer here.

session.go Show resolved Hide resolved
@Stebalien Stebalien force-pushed the fix/keepalive-race branch 2 times, most recently from 4daa05b to ae174bd Compare March 15, 2020 22:19
* fix races
* fix timeouts
* disable some tests when the race detector is enabled (too slow, too many goroutines)
@Stebalien Stebalien merged commit 97856b4 into master Mar 16, 2020
@Stebalien
Copy link
Member Author

Ok, tests aren't perfect but they're much better.

@Stebalien Stebalien deleted the fix/keepalive-race branch March 16, 2020 06:33
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.

runtime error: racy use of timers
3 participants