Skip to content

Commit ed6112f

Browse files
committed
SWPTP-1523: clockfeed: propagate sample errors to consumer
1 parent 5605a7b commit ed6112f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/sfptpd_clockfeed.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static void clockfeed_on_timer(void *user_context, unsigned int id)
368368
else
369369
sfptpd_time_zero(&record->snapshot);
370370

371-
DBG_L6("%s: %llu: %llu: %d: "
371+
DBG_L6("%s: cycle %llu: write_counter %llu: rc %d: "
372372
SFPTPD_FMT_SFTIMESPEC " " SFPTPD_FMT_SFTIMESPEC "\n",
373373
sfptpd_clock_get_short_name(source->clock),
374374
source->cycles, source->shm.write_counter, record->rc,
@@ -876,7 +876,6 @@ static int clockfeed_compare_to_sys(struct sfptpd_clockfeed_sub *sub,
876876
struct sfptpd_timespec age;
877877
int writer1;
878878
int writer2;
879-
int rc = 0;
880879

881880
sfptpd_time_zero(diff);
882881

@@ -901,7 +900,7 @@ static int clockfeed_compare_to_sys(struct sfptpd_clockfeed_sub *sub,
901900
sample = &shm->samples[(writer1 - 1) & index_mask];
902901

903902
if (sample->rc != 0)
904-
return rc;
903+
return sample->rc;
905904

906905
sfptpd_time_subtract(diff, &sample->snapshot, &sample->system);
907906

@@ -919,10 +918,8 @@ static int clockfeed_compare_to_sys(struct sfptpd_clockfeed_sub *sub,
919918
sfptpd_clock_get_short_name(clock), writer1, sub->min_counter);
920919
return ESTALE;
921920
}
922-
if (sub->have_max_age) {
923-
rc = sfclock_gettime(CLOCK_MONOTONIC, &now_mono);
924-
if (rc != 0)
925-
return EAGAIN;
921+
if (sub->have_max_age &&
922+
0 == sfclock_gettime(CLOCK_MONOTONIC, &now_mono)) {
926923
sfptpd_time_subtract(&age, &now_mono, &sample->mono);
927924
if (sfptpd_time_cmp(&age, &sub->max_age) > 0) {
928925
WARNING(PREFIX "%s: sample too old\n",
@@ -936,11 +933,11 @@ static int clockfeed_compare_to_sys(struct sfptpd_clockfeed_sub *sub,
936933
*t2 = sample->system;
937934
if (mono_time)
938935
*mono_time = sample->mono;
939-
if (rc == 0) {
936+
if (sample->rc == 0) {
940937
sub->read_counter = writer1;
941938
}
942939

943-
return rc;
940+
return sample->rc;
944941
}
945942

946943
int sfptpd_clockfeed_compare(struct sfptpd_clockfeed_sub *sub1,

0 commit comments

Comments
 (0)