Remove unnecessary adjtimex calls
This commit is contained in:
parent
62027f1b47
commit
8aa9eb19c8
6 changed files with 32 additions and 7 deletions
|
@ -570,7 +570,10 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
|
|||
version = NTP_VERSION;
|
||||
}
|
||||
|
||||
LCL_ReadCookedTime(&local_transmit, NULL);
|
||||
/* This is accurate enough and cheaper than calling LCL_ReadCookedTime.
|
||||
A more accurate time stamp will be taken later in this function. */
|
||||
SCH_GetLastEventTime(&local_transmit, NULL, NULL);
|
||||
|
||||
REF_GetReferenceParams(&local_transmit,
|
||||
&are_we_synchronised, &leap_status,
|
||||
&our_stratum,
|
||||
|
|
8
ntp_io.c
8
ntp_io.c
|
@ -296,7 +296,7 @@ read_from_socket(void *anything)
|
|||
ReceiveBuffer message;
|
||||
union sockaddr_in46 where_from;
|
||||
unsigned int flags = 0;
|
||||
struct timeval now;
|
||||
struct timeval now, now_raw;
|
||||
double now_err;
|
||||
NTP_Remote_Address remote_addr;
|
||||
char cmsgbuf[256];
|
||||
|
@ -306,7 +306,7 @@ read_from_socket(void *anything)
|
|||
|
||||
assert(initialised);
|
||||
|
||||
SCH_GetLastEventTime(&now, &now_err, NULL);
|
||||
SCH_GetLastEventTime(&now, &now_err, &now_raw);
|
||||
|
||||
iov.iov_base = message.arbitrary;
|
||||
iov.iov_len = sizeof(message);
|
||||
|
@ -376,7 +376,9 @@ read_from_socket(void *anything)
|
|||
struct timeval tv;
|
||||
|
||||
memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv));
|
||||
LCL_CookTime(&tv, &now, &now_err);
|
||||
|
||||
/* This should be more accurate than LCL_CookTime(&now_raw,...) */
|
||||
UTI_AddDiffToTimeval(&now, &now_raw, &tv, &now);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -684,7 +684,7 @@ REF_SetReference(int stratum,
|
|||
double update_interval;
|
||||
double elapsed;
|
||||
double correction_rate;
|
||||
struct timeval now, raw_now;
|
||||
struct timeval now, raw_now, ev_now, ev_raw_now;
|
||||
|
||||
assert(initialised);
|
||||
|
||||
|
@ -713,7 +713,10 @@ REF_SetReference(int stratum,
|
|||
}
|
||||
|
||||
LCL_ReadRawTime(&raw_now);
|
||||
LCL_CookTime(&raw_now, &now, NULL);
|
||||
|
||||
/* This is cheaper than calling LCL_CookTime */
|
||||
SCH_GetLastEventTime(&ev_now, NULL, &ev_raw_now);
|
||||
UTI_AddDiffToTimeval(&ev_now, &ev_raw_now, &raw_now, &now);
|
||||
|
||||
UTI_DiffTimevalsToDouble(&elapsed, &now, ref_time);
|
||||
our_offset = offset + elapsed * frequency;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "reports.h"
|
||||
#include "nameserv.h"
|
||||
#include "mkdirpp.h"
|
||||
#include "sched.h"
|
||||
|
||||
/* ================================================== */
|
||||
/* Flag indicating that we are initialised */
|
||||
|
@ -448,7 +449,8 @@ SRC_SelectSource(uint32_t match_refid)
|
|||
return;
|
||||
}
|
||||
|
||||
LCL_ReadCookedTime(&now, NULL);
|
||||
/* This is accurate enough and cheaper than calling LCL_ReadCookedTime */
|
||||
SCH_GetLastEventTime(&now, NULL, NULL);
|
||||
|
||||
/* Step 1 - build intervals about each source */
|
||||
n_endpoints = 0;
|
||||
|
|
12
util.c
12
util.c
|
@ -188,6 +188,18 @@ UTI_AverageDiffTimevals (struct timeval *earlier,
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
UTI_AddDiffToTimeval(struct timeval *a, struct timeval *b,
|
||||
struct timeval *c, struct timeval *result)
|
||||
{
|
||||
double diff;
|
||||
|
||||
UTI_DiffTimevalsToDouble(&diff, a, b);
|
||||
UTI_AddDoubleToTimeval(c, diff, result);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
#define POOL_ENTRIES 16
|
||||
#define BUFFER_LENGTH 64
|
||||
static char buffer_pool[POOL_ENTRIES][BUFFER_LENGTH];
|
||||
|
|
3
util.h
3
util.h
|
@ -63,6 +63,9 @@ extern void UTI_AddDoubleToTimeval(struct timeval *start, double increment, stru
|
|||
/* Calculate the average and difference (as a double) of two timevals */
|
||||
extern void UTI_AverageDiffTimevals(struct timeval *earlier, struct timeval *later, struct timeval *average, double *diff);
|
||||
|
||||
/* Calculate result = a - b + c */
|
||||
extern void UTI_AddDiffToTimeval(struct timeval *a, struct timeval *b, struct timeval *c, struct timeval *result);
|
||||
|
||||
/* Convert a timeval into a temporary string, largely for diagnostic
|
||||
display */
|
||||
extern char *UTI_TimevalToString(struct timeval *tv);
|
||||
|
|
Loading…
Reference in a new issue