Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Partial workaround for timer during a clock jump #196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vincentbernat
Copy link
Contributor

@vincentbernat vincentbernat commented Jan 2, 2017

time.Now() uses the wall-clock and therefore calling it twice, one
second apart, can produce quite different results (negative results but
also a difference greater than one second). Go doesn't expose a
monotonic clock, therefore, it's difficult to properly fix (but there is
https://github.com/gavv/monotime if we want a proper fix for
timer.Time()).

This workaround just discard any negative duration.

There are other places that incorrectly uses time.Now(). I can add a similar check or I can import monotime to properly fixes them.

`time.Now()` uses the wall-clock and therefore calling it twice, one
second apart, can produce quite different results (negative results but
also a difference greater than one second). Go doesn't expose a
monotonic clock, therefore, it's difficult to properly fix (but there is
https://github.com/gavv/monotime if we want a proper fix for
`timer.Time()`).

This workaround just discard any negative duration.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant