From c13b90631df5a49239a321369b406fc9b56af501 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 10 Oct 2023 14:48:33 -0700 Subject: [PATCH] client: New epoch if seq wraps --- client/net.c | 4 +++- client/net.h | 2 ++ client/tattlekey.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/net.c b/client/net.c index fa5d07b..3d4be8c 100644 --- a/client/net.c +++ b/client/net.c @@ -34,7 +34,7 @@ static void net_local_init() { if (the_pcb) return; - epoch = get_rand_32(); + new_epoch(); the_pcb = udp_new(); if (!the_pcb) @@ -48,6 +48,8 @@ static void net_local_init() { signal_error_by_blinking(); } +void new_epoch() { epoch = get_rand_32(); } + struct tattle_message_wire_format { u32_t epoch; u16_t sender; diff --git a/client/net.h b/client/net.h index 9b8fc1f..31e5cc4 100644 --- a/client/net.h +++ b/client/net.h @@ -22,4 +22,6 @@ void send_report_packet(u16_t seq, u32_t ago); +void new_epoch(); + #endif diff --git a/client/tattlekey.c b/client/tattlekey.c index f9b74c1..5e829d1 100644 --- a/client/tattlekey.c +++ b/client/tattlekey.c @@ -119,6 +119,8 @@ void service_queue() { switch (e.type) { case NEW_BUTTON_PRESS: { add_press(pp, &(press_t){e.buttonpress.timestamp, seq++, 0}); + if (seq == 0) + new_epoch(); } break; case RESEND_TIME: { /* OK, we're awake. Cool. Thanks! (We actually do the sends in the -- 2.44.1