-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
NTPClient: ignore invalid timestamps #2041
Conversation
Sming/Core/Network/NtpClient.cpp
Outdated
if(mode == NTP_MODE_SERVER && (ver == NTP_VERSION || ver == (NTP_VERSION - 1))) { | ||
//Most likely a correct NTP packet received. | ||
if(mode != NTP_MODE_SERVER || (ver != NTP_VERSION && ver != (NTP_VERSION - 1))) { | ||
// Got a dodgy packet so treat it as we would a response failure |
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 the "reflowing" of the code. Can you please change this original comment // Got a dodgy packet so treat it as we would a response failure
to // Got a dodgy packet - ignore it and retry
?
Some things to fix before we can merge this PR
You can run:
|
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.
All good. I do have a suggestion for more self-documenting code:
auto retry = [this]() { startTimer(NTP_RESPONSE_TIMEOUT_MS); };
if(mode != NTP_MODE_SERVER) {
return retry();
}
if(ver != NTP_VERSION && ver != (NTP_VERSION - 1)) {
return retry();
}
...
if(timestamp == 0) {
return retry();
}
@fooker Don't worry about appveyor - rebase will fix that. |
This fixes #2040 by checking against
0
timestamps.