summaryrefslogtreecommitdiff
path: root/src/opentracker.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-28 22:16:45 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-28 22:16:45 +0100
commit03d044b88dd1377281caa44c0133d9f22579ba90 (patch)
tree216c88a5344c2299c5120b035433e96d1fd2f91a /src/opentracker.c
parentfdbd31bbb3e61cc42c2d12371975b892934dd51c (diff)
Add a generation to a task on the workqueue to prevent its result being sent to the next client reusing the fd
Diffstat (limited to 'src/opentracker.c')
-rw-r--r--src/opentracker.c9
1 files changed, 8 insertions, 1 deletions
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 @@
25#include "ot_config.h" 25#include "ot_config.h"
26#include "ot_hex.h" 26#include "ot_hex.h"
27#include "ot_http.h" 27#include "ot_http.h"
28#include "ot_iovec.h"
28#include "ot_ip.h" 29#include "ot_ip.h"
29#include "ot_livesync.h" 30#include "ot_livesync.h"
30#include "ot_mutex.h" 31#include "ot_mutex.h"
@@ -107,6 +108,7 @@ static void *server_mainloop(void *args) {
107 struct iovec *iovector; 108 struct iovec *iovector;
108 size_t iovec_entries; 109 size_t iovec_entries;
109 int is_partial; 110 int is_partial;
111 uint32_t generation;
110 112
111 (void)args; 113 (void)args;
112 114
@@ -149,8 +151,13 @@ static void *server_mainloop(void *args) {
149 } 151 }
150 } 152 }
151 153
152 while ((sock = workqueue_popresult(&iovec_entries, &iovector, &is_partial)) != -1) 154 while ((sock = workqueue_popresult(&iovec_entries, &iovector, &is_partial, &generation)) != -1) {
155 if (fdstate_generation((int)sock) != generation) {
156 iovec_free(&iovec_entries, &iovector);
157 continue;
158 }
153 http_sendiovecdata(sock, &ws, iovec_entries, iovector, is_partial); 159 http_sendiovecdata(sock, &ws, iovec_entries, iovector, is_partial);
160 }
154 161
155 if (time_is_past(next_timeout_check)) { 162 if (time_is_past(next_timeout_check)) {
156 int cursor = 0; 163 int cursor = 0;