Merge pull request #1990 from DeepChannel/fix/nanos-rollover

fix: possible rollover of nanoseconds in clock.h
This commit is contained in:
Max Brunsfeld 2023-02-01 13:15:32 -08:00 committed by GitHub
commit e021d6e979
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,6 +82,10 @@ static inline TSClock clock_after(TSClock base, TSDuration duration) {
TSClock result = base;
result.tv_sec += duration / 1000000;
result.tv_nsec += (duration % 1000000) * 1000;
if (result.tv_nsec >= 1000000000) {
result.tv_nsec -= 1000000000;
++(result.tv_sec);
}
return result;
}