]> git.ipfire.org Git - thirdparty/nqptp.git/commitdiff
clock becoming master was using obselete information, and quieten a warning.
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Wed, 7 Jul 2021 21:36:45 +0000 (21:36 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Wed, 7 Jul 2021 21:36:45 +0000 (21:36 +0000)
nqptp-clock-sources.c
nqptp-message-handlers.c

index b1735155cf2289ee0fdf30e0c503661ed838666f..a3ca06f157c55243138a782c40dc8ad43da2b6b2 100644 (file)
@@ -265,7 +265,6 @@ void update_master() {
 
     if (old_master != best_so_far) {
       // if the naster is a new one
-      clocks_private[best_so_far].previous_offset_time = 0; // resync
       clocks_private[best_so_far].flags |= (1 << clock_is_becoming_master);
     } else {
       // if its the same one as before
index 46e91dac3ab0275bbe77b678a9aebeb5c67d140c..7e7f7dce8eca226165920be926afbc97b6e0085b 100644 (file)
@@ -245,6 +245,11 @@ void handle_follow_up(char *buf, __attribute__((unused)) ssize_t recv_len,
 
   debug(2, "FOLLOWUP from %" PRIx64 ", %s.", clock_private_info->clock_id, &clock_private_info->ip);
   uint64_t offset = preciseOriginTimestamp - reception_time;
+  
+  clock_private_info->local_time = reception_time;
+  clock_private_info->source_time = preciseOriginTimestamp;
+  clock_private_info->local_to_source_time_offset = offset;
+  
   int64_t jitter = 0;
 
     if ((clock_private_info->flags & (1 << clock_is_becoming_master)) != 0) {
@@ -336,6 +341,7 @@ void handle_follow_up(char *buf, __attribute__((unused)) ssize_t recv_len,
             0.000001 * (reception_time - age_of_oldest_legitimate_sample));
       clock_private_info->flags &= ~(1 << clock_is_becoming_master);
       clock_private_info->flags |= 1 << clock_is_master;
+      clock_private_info->previous_offset_time = 0;
     } else if (clock_private_info->previous_offset_time != 0) {
       // i.e. if it's not becoming a master and there has been a previous follow_up
     int64_t time_since_last_sync = reception_time - clock_private_info->last_sync_time;
@@ -373,7 +379,7 @@ void handle_follow_up(char *buf, __attribute__((unused)) ssize_t recv_len,
         offset = clock_private_info->previous_offset + jitter;
       }
     } else if ((clock_private_info->flags & (1 << clock_is_master)) != 0) {
-      warn("Lost sync with clock %" PRIx64 " at %s. Resynchronising.", clock_private_info->clock_id,
+      debug(1, "Lost sync with clock %" PRIx64 " at %s. Resynchronising.", clock_private_info->clock_id,
            clock_private_info->ip);
       // leave the offset as it was coming in and take it as a sync time
       clock_private_info->last_sync_time = reception_time;
@@ -382,10 +388,6 @@ void handle_follow_up(char *buf, __attribute__((unused)) ssize_t recv_len,
     clock_private_info->last_sync_time = reception_time;
   }
 
-  clock_private_info->local_time = reception_time;
-  clock_private_info->source_time = preciseOriginTimestamp;
-  clock_private_info->local_to_source_time_offset = offset;
-
   if ((clock_private_info->flags & (1 << clock_is_master)) != 0) {
     update_master_clock_info(clock_private_info->clock_id, (const char *)&clock_private_info->ip,
                              reception_time, offset, clock_private_info->mastership_start_time);