diff --git a/sources.c b/sources.c index dc8de91..c840e1b 100644 --- a/sources.c +++ b/sources.c @@ -1010,10 +1010,10 @@ SRC_SelectSource(SRC_Instance updated_inst) n_unreach_sources++; si = &sources[i]->sel_info; - SST_GetSelectionData(sources[i]->stats, &now, - &si->lo_limit, &si->hi_limit, &si->root_distance, - &si->std_dev, &first_sample_ago, - &si->last_sample_ago, &si->select_ok); + si->select_ok = SST_GetSelectionData(sources[i]->stats, &now, + &si->lo_limit, &si->hi_limit, &si->root_distance, + &si->std_dev, &first_sample_ago, + &si->last_sample_ago); if (!si->select_ok) { ++n_badstats_sources; diff --git a/sourcestats.c b/sourcestats.c index 8010540..047cf8f 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -644,22 +644,16 @@ SST_GetFrequencyRange(SST_Stats inst, /* ================================================== */ -void -SST_GetSelectionData(SST_Stats inst, struct timespec *now, - double *offset_lo_limit, - double *offset_hi_limit, - double *root_distance, - double *std_dev, - double *first_sample_ago, - double *last_sample_ago, - int *select_ok) +int +SST_GetSelectionData(SST_Stats inst, struct timespec *now, double *offset_lo_limit, + double *offset_hi_limit, double *root_distance, double *std_dev, + double *first_sample_ago, double *last_sample_ago) { double offset, sample_elapsed; int i, j; if (!inst->n_samples) { - *select_ok = 0; - return; + return 0; } i = get_runsbuf_index(inst, inst->best_single_sample); @@ -680,19 +674,20 @@ SST_GetSelectionData(SST_Stats inst, struct timespec *now, i = get_runsbuf_index(inst, inst->n_samples - 1); *last_sample_ago = UTI_DiffTimespecsToDouble(now, &inst->sample_times[i]); - *select_ok = inst->regression_ok; - /* If maxsamples is too small to have a successful regression, enable the selection as a special case for a fast update/print-once reference mode */ - if (!*select_ok && inst->n_samples < MIN_SAMPLES_FOR_REGRESS && + if (!inst->regression_ok && inst->n_samples < MIN_SAMPLES_FOR_REGRESS && inst->n_samples == inst->max_samples) { *std_dev = CNF_GetMaxJitter(); - *select_ok = 1; + } else if (!inst->regression_ok) { + return 0; } - DEBUG_LOG("n=%d off=%f dist=%f sd=%f first_ago=%f last_ago=%f selok=%d", + DEBUG_LOG("n=%d off=%f dist=%f sd=%f first_ago=%f last_ago=%f", inst->n_samples, offset, *root_distance, *std_dev, - *first_sample_ago, *last_sample_ago, *select_ok); + *first_sample_ago, *last_sample_ago); + + return 1; } /* ================================================== */ diff --git a/sourcestats.h b/sourcestats.h index e10f425..ef50f62 100644 --- a/sourcestats.h +++ b/sourcestats.h @@ -67,15 +67,10 @@ extern void SST_DoNewRegression(SST_Stats inst); extern void SST_GetFrequencyRange(SST_Stats inst, double *lo, double *hi); /* Get data needed for selection */ -extern void -SST_GetSelectionData(SST_Stats inst, struct timespec *now, - double *offset_lo_limit, - double *offset_hi_limit, - double *root_distance, - double *variance, - double *first_sample_ago, - double *last_sample_ago, - int *select_ok); +extern int SST_GetSelectionData(SST_Stats inst, struct timespec *now, + double *offset_lo_limit, double *offset_hi_limit, + double *root_distance, double *variance, + double *first_sample_ago, double *last_sample_ago); /* Get data needed when setting up tracking on this source */ extern void