reference: return real sync status in REF_GetReferenceParams()
If local reference is active, return normal leap, but unsynchronised status. Update the callers of the function to work with the leap directly and not change their behaviour. REF_IsLocalActive() is no longer needed.
This commit is contained in:
parent
10719d6d35
commit
2aab6a85a4
4 changed files with 11 additions and 24 deletions
12
ntp_core.c
12
ntp_core.c
|
@ -801,7 +801,7 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
|
|||
)
|
||||
{
|
||||
NTP_Packet message;
|
||||
int leap, auth_len, length, ret, precision;
|
||||
int auth_len, length, ret, precision;
|
||||
struct timeval local_receive, local_transmit;
|
||||
NTP_int64 ts_fuzz;
|
||||
|
||||
|
@ -823,7 +823,7 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
|
|||
if (my_mode == MODE_CLIENT) {
|
||||
/* Don't reveal local time or state of the clock in client packets */
|
||||
precision = 32;
|
||||
are_we_synchronised = leap_status = our_stratum = our_ref_id = 0;
|
||||
leap_status = our_stratum = our_ref_id = 0;
|
||||
our_ref_time.tv_sec = our_ref_time.tv_usec = 0;
|
||||
our_root_delay = our_root_dispersion = 0.0;
|
||||
} else {
|
||||
|
@ -859,14 +859,8 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
|
|||
local_receive = *local_rx;
|
||||
}
|
||||
|
||||
if (are_we_synchronised) {
|
||||
leap = (int) leap_status;
|
||||
} else {
|
||||
leap = LEAP_Unsynchronised;
|
||||
}
|
||||
|
||||
/* Generate transmit packet */
|
||||
message.lvm = NTP_LVM(leap, version, my_mode);
|
||||
message.lvm = NTP_LVM(leap_status, version, my_mode);
|
||||
/* Stratum 16 and larger are invalid */
|
||||
if (our_stratum < NTP_MAX_STRATUM) {
|
||||
message.stratum = our_stratum;
|
||||
|
|
12
refclock.c
12
refclock.c
|
@ -470,15 +470,16 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
|||
double root_delay, root_dispersion, distance;
|
||||
uint32_t ref_id;
|
||||
|
||||
/* Ignore the pulse if we are not well synchronized */
|
||||
/* Ignore the pulse if we are not well synchronized and the local
|
||||
reference is not active */
|
||||
|
||||
REF_GetReferenceParams(&cooked_time, &is_synchronised, &leap, &stratum,
|
||||
&ref_id, &ref_time, &root_delay, &root_dispersion);
|
||||
distance = fabs(root_delay) / 2 + root_dispersion;
|
||||
|
||||
if (!is_synchronised || distance >= 0.5 / rate) {
|
||||
if (leap == LEAP_Unsynchronised || distance >= 0.5 / rate) {
|
||||
DEBUG_LOG(LOGF_Refclock, "refclock pulse ignored second=%.9f sync=%d dist=%.9f",
|
||||
second, is_synchronised, distance);
|
||||
second, leap != LEAP_Unsynchronised, distance);
|
||||
/* Drop also all stored samples */
|
||||
filter_reset(&instance->filter);
|
||||
return 0;
|
||||
|
@ -528,9 +529,10 @@ pps_stratum(RCL_Instance instance, struct timeval *tv)
|
|||
REF_GetReferenceParams(tv, &is_synchronised, &leap, &stratum,
|
||||
&ref_id, &ref_time, &root_delay, &root_dispersion);
|
||||
|
||||
/* Don't change our stratum if local stratum is active
|
||||
/* Don't change our stratum if the local reference is active
|
||||
or this is the current source */
|
||||
if (ref_id == instance->ref_id || REF_IsLocalActive())
|
||||
if (ref_id == instance->ref_id ||
|
||||
(!is_synchronised && leap != LEAP_Unsynchronised))
|
||||
return stratum - 1;
|
||||
|
||||
/* Or the current source is another PPS refclock */
|
||||
|
|
10
reference.c
10
reference.c
|
@ -1223,7 +1223,7 @@ REF_GetReferenceParams
|
|||
|
||||
} else if (enable_local_stratum) {
|
||||
|
||||
*is_synchronised = 1;
|
||||
*is_synchronised = 0;
|
||||
|
||||
*stratum = local_stratum;
|
||||
*ref_id = NTP_REFID_LOCAL;
|
||||
|
@ -1331,14 +1331,6 @@ REF_DisableLocal(void)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
int
|
||||
REF_IsLocalActive(void)
|
||||
{
|
||||
return !are_we_synchronised && enable_local_stratum;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
#define LEAP_SECOND_CLOSE 5
|
||||
|
||||
int REF_IsLeapSecondClose(void)
|
||||
|
|
|
@ -179,7 +179,6 @@ extern void REF_ModifyMakestep(int limit, double threshold);
|
|||
|
||||
extern void REF_EnableLocal(int stratum, double distance, int orphan);
|
||||
extern void REF_DisableLocal(void);
|
||||
extern int REF_IsLocalActive(void);
|
||||
|
||||
/* Check if current raw or cooked time is close to a leap second
|
||||
and is better to discard any measurements */
|
||||
|
|
Loading…
Reference in a new issue