-
Notifications
You must be signed in to change notification settings - Fork 534
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
lastSent/keepAlive logic should not use wall clock #300
Comments
I believe you are correct that this could be an issue, the problem is that those values are accessed from different goroutines so use the sync/atomic package for accessing and setting their values. It would need a new struct wrapping a time.Time and a mutex to give the same function. Don't suppose you fancy having a go at doing this? |
I can see if I get some time beginning of next week. I'm not really sure about the need for struct and mutex though. The code right now uses |
ok cool, hadn't used atomic.Value before, I'll look at doing that |
I have tried to make a pull request for this, put I can't seem to get the license thing to work. But I have a "Eclipse Contributor Agreement" green checkbox on my profile. I only get "This validation request is closed or unavailable." when clicking "details". |
I happened to look through the source code and saw that
lastSent
/lastReceived
uses epoch time. But the logic for keepAlive should really use time elapsed. Therefore I suggest thatlastSent int64
andlastReceived int64
usestime.Time
instead. Then when comparing times the monotonic clock will be used instead.With the current logic the keep alive will break if the wall clock on the computer is changed.
Please advice if I have missunderstood something or if someone have a better solution.
The text was updated successfully, but these errors were encountered: