mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 00:55:06 -05:00
ntp: don't replace source instance when changing address
Add new functions to change source's reference ID/address and reset the instance. Use that instead of destroying and creating a new instance when the NTP address is changed.
This commit is contained in:
11
ntp_core.c
11
ntp_core.c
@@ -541,8 +541,6 @@ NCR_ResetInstance(NCR_Instance instance)
|
||||
void
|
||||
NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr)
|
||||
{
|
||||
SRC_SelectOption sel_option;
|
||||
|
||||
inst->remote_addr = *remote_addr;
|
||||
inst->tx_count = 0;
|
||||
inst->presend_done = 0;
|
||||
@@ -552,11 +550,10 @@ NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remote_addr)
|
||||
else
|
||||
inst->local_addr.sock_fd = NIO_GetServerSocket(remote_addr);
|
||||
|
||||
/* Replace sources and sourcestats instances */
|
||||
sel_option = SRC_GetSelectOption(inst->source);
|
||||
SRC_DestroyInstance(inst->source);
|
||||
inst->source = SRC_CreateNewInstance(UTI_IPToRefid(&remote_addr->ip_addr), SRC_NTP,
|
||||
sel_option, &inst->remote_addr.ip_addr);
|
||||
/* Update the reference ID and reset the source/sourcestats instances */
|
||||
SRC_SetRefid(inst->source, UTI_IPToRefid(&remote_addr->ip_addr),
|
||||
&inst->remote_addr.ip_addr);
|
||||
SRC_ResetInstance(inst->source);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
Reference in New Issue
Block a user