Add isc_time_now_hires function to get current time with high resolution

The current isc_time_now uses CLOCK_REALTIME_COARSE which only updates
on a timer tick. This clock is generally fine for millisecond accuracy,
but on servers with 100hz clocks, this clock is nowhere near accurate
enough for microsecond accuracy.

This commit adds a new isc_time_now_hires function that uses
CLOCK_REALTIME, which gives the current time, though it is somewhat
expensive to call. When microsecond accuracy is required, it may be
required to use extra resources for higher accuracy.
This commit is contained in:
Patrick McLean
2021-03-19 22:48:22 -07:00
committed by Evan Hunt
parent bee4ee931f
commit ebced74b19
7 changed files with 75 additions and 5 deletions

View File

@@ -164,6 +164,26 @@ isc_time_now(isc_time_t *t);
* in the current definition of isc_time_t.
*/
isc_result_t
isc_time_now_hires(isc_time_t *t);
/*%<
* Set 't' to the current absolute time. Uses higher resolution clocks
* recommended when microsecond accuracy is required.
*
* Requires:
*
*\li 't' is a valid pointer.
*
* Returns:
*
*\li Success
*\li Unexpected error
* Getting the time from the system failed.
*\li Out of range
* The time from the system is too large to be represented
* in the current definition of isc_time_t.
*/
isc_result_t
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i);
/*