mirror of
https://gitlab.com/chrony/chrony.git
synced 2026-01-21 21:30:19 -05:00
cmdmon: refactor handling of sources report
The NSR_ReportSource() and RCL_ReportSource() functions assume that the provided report already has some data prefilled by SRC_ReportSource() and it's assumed these functions cannot fail. Change them to accept the required data (refid and IP address) as a parameter, remove unneeded parameters, and return an error status (if the refid/address doesn't exist) to be handled in cmdmon handle_source_data(). Also, catch unexpected values of the source state and mode to make chronyc report an error instead of incorrect data.
This commit is contained in:
@@ -1523,20 +1523,17 @@ NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples,
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
/* The ip address is assumed to be completed on input, that is how we
|
||||
identify the source record. */
|
||||
|
||||
void
|
||||
NSR_ReportSource(RPT_SourceReport *report, struct timespec *now)
|
||||
int
|
||||
NSR_ReportSource(IPAddr *ip_addr, RPT_SourceReport *report)
|
||||
{
|
||||
int slot;
|
||||
|
||||
if (find_slot(&report->ip_addr, &slot)) {
|
||||
NCR_ReportSource(get_record(slot)->data, report, now);
|
||||
} else {
|
||||
report->poll = 0;
|
||||
report->latest_meas_ago = 0;
|
||||
}
|
||||
if (!find_slot(ip_addr, &slot))
|
||||
return 0;
|
||||
|
||||
NCR_ReportSource(get_record(slot)->data, report);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
Reference in New Issue
Block a user