mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:35:06 -05:00
Read local time immediately after select()
This removes a small inaccuracy caused by delay between select() and file handler calls.
This commit is contained in:
13
sched.c
13
sched.c
@@ -71,6 +71,9 @@ typedef struct {
|
||||
|
||||
static FileHandlerEntry file_handlers[FD_SET_SIZE];
|
||||
|
||||
/* Last timestamp when a file descriptor became readable */
|
||||
static struct timeval last_fdready;
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
/* Variables to handler the timer queue */
|
||||
@@ -225,6 +228,14 @@ SCH_RemoveInputFileHandler(int fd)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
SCH_GetFileReadyTime(struct timeval *tv)
|
||||
{
|
||||
*tv = last_fdready;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
#define TQE_ALLOC_QUANTUM 32
|
||||
|
||||
static TimerQueueEntry *
|
||||
@@ -514,6 +525,7 @@ SCH_MainLoop(void)
|
||||
int status;
|
||||
struct timeval tv, *ptv;
|
||||
struct timeval now;
|
||||
double err;
|
||||
|
||||
if (!initialised) {
|
||||
CROAK("Should be initialised");
|
||||
@@ -551,6 +563,7 @@ SCH_MainLoop(void)
|
||||
}
|
||||
|
||||
status = select(one_highest_fd, &rd, NULL, NULL, ptv);
|
||||
LCL_ReadCookedTime(&last_fdready, &err);
|
||||
|
||||
if (status < 0) {
|
||||
if (!need_to_exit)
|
||||
|
||||
Reference in New Issue
Block a user