ntp: delay enabling permanent kernel RX timestamping on Linux
Wait until a kernel RX timestamp is actually missing before opening the dummy socket in order to avoid a small performance impact in case the servers are so slow/distant that the kernel can constantly win the race.
This commit is contained in:
parent
8e4c776900
commit
8b1f68b1b4
1 changed files with 9 additions and 3 deletions
|
@ -397,9 +397,7 @@ NIO_Linux_Initialise(void)
|
|||
|
||||
monitored_socket = INVALID_SOCK_FD;
|
||||
suspended_socket = INVALID_SOCK_FD;
|
||||
|
||||
/* Open a socket to keep the kernel RX timestamping permanently enabled */
|
||||
dummy_rxts_socket = open_dummy_socket();
|
||||
dummy_rxts_socket = INVALID_SOCK_FD;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -763,6 +761,14 @@ NIO_Linux_ProcessMessage(NTP_Remote_Address *remote_addr, NTP_Local_Address *loc
|
|||
}
|
||||
}
|
||||
|
||||
/* If the kernel is slow with enabling RX timestamping, open a dummy
|
||||
socket to keep the kernel RX timestamping permanently enabled */
|
||||
if (!is_tx && local_ts->source == NTP_TS_DAEMON && ts_flags) {
|
||||
DEBUG_LOG("Missing kernel RX timestamp");
|
||||
if (dummy_rxts_socket == INVALID_SOCK_FD)
|
||||
dummy_rxts_socket = open_dummy_socket();
|
||||
}
|
||||
|
||||
/* Return the message if it's not received from the error queue */
|
||||
if (!is_tx)
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue