]> git.ipfire.org Git - thirdparty/nqptp.git/commitdiff
Don't die if the clock table is full or address list is malformed -- just ignore...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Tue, 30 Nov 2021 17:54:38 +0000 (17:54 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Tue, 30 Nov 2021 17:54:38 +0000 (17:54 +0000)
nqptp-clock-sources.c
nqptp-message-handlers.c
nqptp-shm-structures.h
nqptp.c

index ef95bdd9f6afaaf8a1cb2eb95b2923f95d1b0bcd..90349c9a31227ce00ce48c6ee71460da9b5bace6 100644 (file)
@@ -58,12 +58,11 @@ int find_clock_source_record(char *sender_string, clock_source_private_data *clo
 
 int create_clock_source_record(char *sender_string,
                                clock_source_private_data *clocks_private_info) {
-  // sometimes, the mutex will already be locked
-  // return the index of a clock entry in the clock information arrays or -1 if full
+   // return the index of a clock entry in the clock information arrays or -1 if full
   // initialise the entries in the shared and private arrays
   int response = -1;
   int i = 0;
-  int found = 0;
+  int found = 0; // trying to find an unused entry
   while ((found == 0) && (i < MAX_CLOCKS)) {
     if (clocks_private_info[i].in_use == 0)
       found = 1;
@@ -92,10 +91,10 @@ int create_clock_source_record(char *sender_string,
       debug(2, "create record for ip: %s, family: %s.", &clocks_private_info[i].ip,
             clocks_private_info[i].family == AF_INET6 ? "IPv6" : "IPv4");
     } else {
-      die("cannot getaddrinfo for ip: %s.", &clocks_private_info[i].ip);
+      debug(1, "cannot getaddrinfo for ip: %s.", &clocks_private_info[i].ip);
     }
   } else {
-    die("Clock tables full!");
+    debug(1, "Clock tables full!");
   }
   return response;
 }
index acfa56103875a89b2a54adcc5b9c2c393a9f978e..fafb3a40565eaee67a719d105aba48702fec50c0 100644 (file)
@@ -50,7 +50,9 @@ void handle_control_port_messages(char *buf, ssize_t recv_len,
           int t = find_clock_source_record(new_ip, clock_private_info);
           if (t == -1)
             t = create_clock_source_record(new_ip, clock_private_info);
-          clock_private_info[t].flags |= (1 << clock_is_a_timing_peer);
+          if (t != -1) // if the clock table is not full, show it's a timing peer
+            clock_private_info[t].flags |= (1 << clock_is_a_timing_peer);
+          // otherwise, drop it
         }
       }
 
index f4db8c6e291d95aeeaa83fe0e4a469c79a07f658..f5edbd48c0a2053fd4c8a9268c8216f760339ac0 100644 (file)
@@ -21,7 +21,7 @@
 #define NQPTP_SHM_STRUCTURES_H
 
 #define STORAGE_ID "/nqptp"
-#define MAX_CLOCKS 32
+#define MAX_CLOCKS 64
 #define NQPTP_SHM_STRUCTURES_VERSION 6
 #define NQPTP_CONTROL_PORT 9000
 
diff --git a/nqptp.c b/nqptp.c
index 2d676f704fbfe99ce62163300616da19f62cd430..64f85c6986ce1d44ba33a7730bd6ee661363ed14 100644 (file)
--- a/nqptp.c
+++ b/nqptp.c
@@ -178,6 +178,7 @@ int main(int argc, char **argv) {
 
   debug_init(debug_level, 0, 1, 1);
   debug(1, "startup. self clock id: \"%" PRIx64 "\".", get_self_clock_id());
+  debug(1, "size of a clock entry is %u bytes.", sizeof(clock_source_private_data));
   atexit(goodbye);
 
   sockets_open_stuff.sockets_open = 0;
@@ -396,7 +397,7 @@ int main(int argc, char **argv) {
                                        recv_len); // unusual messages will have debug level 1.
                     break;
                   }
-                }
+                } // otherwise, just forget it
               }
             }
           }