ntp: add corrected delay to debug message in process_receive()
This commit is contained in:
parent
af664e6cec
commit
4f10144b09
1 changed files with 12 additions and 8 deletions
20
ntp_io.c
20
ntp_io.c
|
@ -553,10 +553,12 @@ process_receive(struct msghdr *hdr, int length, int sock_fd)
|
||||||
NTP_Remote_Address remote_addr;
|
NTP_Remote_Address remote_addr;
|
||||||
NTP_Local_Address local_addr;
|
NTP_Local_Address local_addr;
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
struct timespec now;
|
struct timespec sch_ts, rx_ts;
|
||||||
double now_err;
|
double sch_err, rx_err;
|
||||||
|
|
||||||
SCH_GetLastEventTime(&now, &now_err, NULL);
|
SCH_GetLastEventTime(&sch_ts, &sch_err, NULL);
|
||||||
|
rx_ts = sch_ts;
|
||||||
|
rx_err = sch_err;
|
||||||
|
|
||||||
if (hdr->msg_namelen > sizeof (union sockaddr_in46)) {
|
if (hdr->msg_namelen > sizeof (union sockaddr_in46)) {
|
||||||
DEBUG_LOG(LOGF_NtpIO, "Truncated source address");
|
DEBUG_LOG(LOGF_NtpIO, "Truncated source address");
|
||||||
|
@ -598,7 +600,7 @@ process_receive(struct msghdr *hdr, int length, int sock_fd)
|
||||||
|
|
||||||
memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv));
|
memcpy(&tv, CMSG_DATA(cmsg), sizeof(tv));
|
||||||
UTI_TimevalToTimespec(&tv, &ts);
|
UTI_TimevalToTimespec(&tv, &ts);
|
||||||
LCL_CookTime(&ts, &now, &now_err);
|
LCL_CookTime(&ts, &rx_ts, &rx_err);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -607,20 +609,22 @@ process_receive(struct msghdr *hdr, int length, int sock_fd)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
memcpy(&ts, CMSG_DATA(cmsg), sizeof (ts));
|
memcpy(&ts, CMSG_DATA(cmsg), sizeof (ts));
|
||||||
LCL_CookTime(&ts, &now, &now_err);
|
LCL_CookTime(&ts, &rx_ts, &rx_err);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(LOGF_NtpIO, "Received %d bytes from %s:%d to %s fd %d",
|
DEBUG_LOG(LOGF_NtpIO, "Received %d bytes from %s:%d to %s fd %d delay %.9f",
|
||||||
length, UTI_IPToString(&remote_addr.ip_addr), remote_addr.port,
|
length, UTI_IPToString(&remote_addr.ip_addr), remote_addr.port,
|
||||||
UTI_IPToString(&local_addr.ip_addr), local_addr.sock_fd);
|
UTI_IPToString(&local_addr.ip_addr), local_addr.sock_fd,
|
||||||
|
UTI_DiffTimespecsToDouble(&sch_ts, &rx_ts));
|
||||||
|
|
||||||
|
|
||||||
/* Just ignore the packet if it's not of a recognized length */
|
/* Just ignore the packet if it's not of a recognized length */
|
||||||
if (length < NTP_NORMAL_PACKET_LENGTH || length > sizeof (NTP_Receive_Buffer))
|
if (length < NTP_NORMAL_PACKET_LENGTH || length > sizeof (NTP_Receive_Buffer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NSR_ProcessReceive((NTP_Packet *)hdr->msg_iov[0].iov_base, &now, now_err,
|
NSR_ProcessReceive((NTP_Packet *)hdr->msg_iov[0].iov_base, &rx_ts, rx_err,
|
||||||
&remote_addr, &local_addr, length);
|
&remote_addr, &local_addr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue