Added packet flush before request in forceUpdate(). Fixes issue #49 - random clock delay #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes issue #49 where the clock is randomly delayed.
The bug is that a response that comes back after the timeout delay is held in the receive buffer until the next update request. That update sends a new request, but processes the OLD response sitting in the buffer. This cycle repeats indefinitely as each new request places a response in the buffer that will be consumed on the NEXT update cycle.
This can easily be verified / recreated by making the sendNTPPacket method public and calling it immediately after a call to update. Then wait for some time (a few seconds or several minutes, depending on the update interval) and then make another request to update (or forceUpdate). The newly updated time will be the OLD time from the response to the extra sendNTPPacket. All subsequent requests will be off by one update interval unless and until a response packet is actually not sent.
The fix is to flush any queued responses before sending the new request. This is what the pull request accomplishes.