summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPancakeTAS <pancake@mgnet.work>2026-06-13 15:21:33 +0200
committerPancakeTAS <pancake@mgnet.work>2026-06-14 16:27:15 +0200
commit2b9c2960b0fcdf618d0f148cea3bea89c1af6c3b (patch)
treefb4f0137377c0e4f753cc2362775983c37194868
parentfeat: Implement two-path UDP context (diff)
fix(mpu): Purge dropped packets from reorder heap
-rw-r--r--src/mpu.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mpu.c b/src/mpu.c
index 32c0ffe..f25f1d8 100644
--- a/src/mpu.c
+++ b/src/mpu.c
@@ -94,8 +94,6 @@ int mpu_send(mpu_ctx_t* ctx, const uint8_t* data, size_t len) {
return 0;
}
-// FIXME: Skipped packages are never purged
-
// TODO: Zero-copy recv() into reorder buffer slot, requiring the user to provide a callback
// for processing received packets, instead of copying into a user buffer.
@@ -137,6 +135,10 @@ ssize_t mpu_recv(mpu_ctx_t* ctx, uint8_t* data, size_t len) {
}
mpu_slot_t* slot = (mpu_slot_t*) node->user;
+ if (slot->packet.hdr.seq_num < ctx->recv_seq_num) {
+ heap_extract(&ctx->reorder_heap);
+ continue;
+ }
int age = (int) (now - slot->timestamp);
if (age < ctx->reorder_window) {