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:
Miroslav Lichvar
2014-12-01 18:01:11 +01:00
parent 308bcae257
commit 42dd5caa1b
5 changed files with 53 additions and 28 deletions

View File

@@ -182,9 +182,8 @@ SST_CreateInstance(uint32_t refid, IPAddr *addr)
{
SST_Stats inst;
inst = MallocNew(struct SST_Stats_Record);
inst->refid = refid;
inst->ip_addr = addr;
SST_SetRefid(inst, refid, addr);
SST_ResetInstance(inst);
return inst;
@@ -220,6 +219,15 @@ SST_ResetInstance(SST_Stats inst)
inst->nruns = 0;
}
/* ================================================== */
void
SST_SetRefid(SST_Stats inst, uint32_t refid, IPAddr *addr)
{
inst->refid = refid;
inst->ip_addr = addr;
}
/* ================================================== */
/* This function is called to prune the register down when it is full.
For now, just discard the oldest sample. */