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;
|
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,
|
REF_GetReferenceParams(&local_transmit,
|
||||||
&are_we_synchronised, &leap_status,
|
&are_we_synchronised, &leap_status,
|
||||||
&our_stratum,
|
&our_stratum,
|
||||||
|
|
8
ntp_io.c
8
ntp_io.c
|
@ -296,7 +296,7 @@ read_from_socket(void *anything)
|
||||||
ReceiveBuffer message;
|
ReceiveBuffer message;
|
||||||
union sockaddr_in46 where_from;
|
union sockaddr_in46 where_from;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
struct timeval now;
|
struct timeval now, now_raw;
|
||||||
double now_err;
|
double now_err;
|
||||||
NTP_Remote_Address remote_addr;
|
NTP_Remote_Address remote_addr;
|
||||||
char cmsgbuf[256];
|
char cmsgbuf[256];
|
||||||
|
@ -306,7 +306,7 @@ read_from_socket(void *anything)
|
||||||
|
|
||||||
assert(initialised);
|
assert(initialised);
|
||||||
|
|
||||||
SCH_GetLastEventTime(&now, &now_err, NULL);
|
SCH_GetLastEventTime(&now, &now_err, &now_raw);
|
||||||
|
|
||||||
iov.iov_base = message.arbitrary;
|
iov.iov_base = message.arbitrary;
|
||||||
iov.iov_len = sizeof(message);
|
iov.iov_len = sizeof(message);
|
||||||
|
@ -376,7 +376,9 @@ read_from_socket(void *anything)
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
memcpy(&tv, CMSG_DATA(cmsg), sizeof(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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,7 +684,7 @@ REF_SetReference(int stratum,
|
||||||
double update_interval;
|
double update_interval;
|
||||||
double elapsed;
|
double elapsed;
|
||||||
double correction_rate;
|
double correction_rate;
|
||||||
struct timeval now, raw_now;
|
struct timeval now, raw_now, ev_now, ev_raw_now;
|
||||||
|
|
||||||
assert(initialised);
|
assert(initialised);
|
||||||
|
|
||||||
|
@ -713,7 +713,10 @@ REF_SetReference(int stratum,
|
||||||
}
|
}
|
||||||
|
|
||||||
LCL_ReadRawTime(&raw_now);
|
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);
|
UTI_DiffTimevalsToDouble(&elapsed, &now, ref_time);
|
||||||
our_offset = offset + elapsed * frequency;
|
our_offset = offset + elapsed * frequency;
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "reports.h"
|
#include "reports.h"
|
||||||
#include "nameserv.h"
|
#include "nameserv.h"
|
||||||
#include "mkdirpp.h"
|
#include "mkdirpp.h"
|
||||||
|
#include "sched.h"
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Flag indicating that we are initialised */
|
/* Flag indicating that we are initialised */
|
||||||
|
@ -448,7 +449,8 @@ SRC_SelectSource(uint32_t match_refid)
|
||||||
return;
|
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 */
|
/* Step 1 - build intervals about each source */
|
||||||
n_endpoints = 0;
|
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 POOL_ENTRIES 16
|
||||||
#define BUFFER_LENGTH 64
|
#define BUFFER_LENGTH 64
|
||||||
static char buffer_pool[POOL_ENTRIES][BUFFER_LENGTH];
|
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 */
|
/* 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);
|
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
|
/* Convert a timeval into a temporary string, largely for diagnostic
|
||||||
display */
|
display */
|
||||||
extern char *UTI_TimevalToString(struct timeval *tv);
|
extern char *UTI_TimevalToString(struct timeval *tv);
|
||||||
|
|
Loading…
Reference in a new issue