The SHM is not cleared upon servo release when exiting the tool. This leaves
the last update in the shared memory region marked as valid. As a result, the
NTP daemon starting later may consume stale data if the producer process
exited.

To prevent such behavior - invalidate the SHM data when releasing the SHM servo.

Signed-off-by: Maciek Machnikowski <mac...@machnikowski.net>
---
 ntpshm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ntpshm.c b/ntpshm.c
index 3b62a3f..6453ac4 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -69,6 +69,9 @@ static void ntpshm_destroy(struct servo *servo)
 {
        struct ntpshm_servo *s = container_of(servo, struct ntpshm_servo, 
servo);
 
+       /* Invalidate the SHM data before exiting */
+       s->shm->valid = 0;
+
        shmdt(s->shm);
        free(s);
 }
-- 
2.37.1 (Apple Git-137.1)



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to