From 5acdcfec6325f9ad526200aca40fe5d0a7660f86 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 21 Nov 2011 20:38:02 +0100 Subject: [PATCH] Limit telegram squashing to 5s total Before, only the time between adjacent telegrams was limited, not the total time. --- src/lib/subs/wu.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/lib/subs/wu.c b/src/lib/subs/wu.c index 84549a0df..b700c3e47 100644 --- a/src/lib/subs/wu.c +++ b/src/lib/subs/wu.c @@ -51,9 +51,7 @@ static struct telstr last_tel[MAXNOC]; void clear_telegram_is_new(natid to) { - last_tel[to].tel_type = 0; last_tel[to].tel_from = NATID_BAD; - last_tel[to].tel_date = 0; } /* @@ -64,18 +62,14 @@ clear_telegram_is_new(natid to) static int telegram_is_new(natid to, struct telstr *tel) { - int is_new = 0; - - is_new |= tel->tel_type != last_tel[to].tel_type; - is_new |= tel->tel_from != last_tel[to].tel_from; - is_new |= tel->tel_type != TEL_UPDATE && - abs(tel->tel_date - last_tel[to].tel_date) > TEL_SECONDS; - - last_tel[to].tel_type = tel->tel_type; - last_tel[to].tel_from = tel->tel_from; - last_tel[to].tel_date = tel->tel_date; - - return is_new; + if (tel->tel_from != last_tel[to].tel_from + || tel->tel_type != last_tel[to].tel_type + || (tel->tel_type != TEL_UPDATE + && abs(tel->tel_date - last_tel[to].tel_date) > TEL_SECONDS)) { + last_tel[to] = *tel; + return 1; + } + return 0; } /* -- 2.43.0