From 03d044b88dd1377281caa44c0133d9f22579ba90 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 28 Nov 2026 22:16:45 +0100 Subject: Add a generation to a task on the workqueue to prevent its result being sent to the next client reusing the fd --- src/opentracker.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/opentracker.c') diff --git a/src/opentracker.c b/src/opentracker.c index 759a6d0..36dff71 100644 --- a/src/opentracker.c +++ b/src/opentracker.c @@ -25,6 +25,7 @@ #include "ot_config.h" #include "ot_hex.h" #include "ot_http.h" +#include "ot_iovec.h" #include "ot_ip.h" #include "ot_livesync.h" #include "ot_mutex.h" @@ -107,6 +108,7 @@ static void *server_mainloop(void *args) { struct iovec *iovector; size_t iovec_entries; int is_partial; + uint32_t generation; (void)args; @@ -149,8 +151,13 @@ static void *server_mainloop(void *args) { } } - while ((sock = workqueue_popresult(&iovec_entries, &iovector, &is_partial)) != -1) + while ((sock = workqueue_popresult(&iovec_entries, &iovector, &is_partial, &generation)) != -1) { + if (fdstate_generation((int)sock) != generation) { + iovec_free(&iovec_entries, &iovector); + continue; + } http_sendiovecdata(sock, &ws, iovec_entries, iovector, is_partial); + } if (time_is_past(next_timeout_check)) { int cursor = 0; -- cgit v1.3