mesh: Fix msg cache ring buffer
authorIsak Westin <isak.westin@loytec.com>
Thu, 6 Oct 2022 14:59:27 +0000 (16:59 +0200)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:55 +0000 (14:55 +0530)
The message cache should be a strict ring buffer, suppressed message
should not move to the front of the queue.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
mesh/net.c

index ad00333..8058b19 100644 (file)
@@ -1024,12 +1024,11 @@ static bool msg_in_cache(struct mesh_net *net, uint16_t src, uint32_t seq,
                .mic = mic,
        };
 
-       msg = l_queue_remove_if(net->msg_cache, match_cache, &tst);
+       msg = l_queue_find(net->msg_cache, match_cache, &tst);
 
        if (msg) {
                l_debug("Supressing duplicate %4.4x + %6.6x + %8.8x",
                                                        src, seq, mic);
-               l_queue_push_head(net->msg_cache, msg);
                return true;
        }