From 4d030871c004c917458b5e1c296edcfc689a2e66 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 31 Oct 2026 15:59:41 +0100 Subject: Make tcp worker multithreaded, too This shamelessly steals the model established in the UDP workers, i.e. if the kernel is able to bind multiple listening sockets to the same endpoint, we will share them across threads. If it can't, all threads will accept on the same socket. The fast path handles most of the connections, only the rare case of no data yet on the socket is offloaded to the slow path (which used to be the mainloop) for completion. This scales nicely, as the higher the load is, the higher chances are that an accept happens only after the network roundtrip to the peer completes, leading to more connections that already have data waiting for us. We also consolidate the workstruct init and deinit code, preparation for later unifying all thread state structs for all protocols (mca, udc and tcp). The config file gains a per tcp connection worker count and some docs explaining what this knob buys and costs, nudging the user to either keep it 0 or dial it up to at least 2. --- trackerlogic.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'trackerlogic.h') diff --git a/trackerlogic.h b/trackerlogic.h index d269267..53edabd 100644 --- a/trackerlogic.h +++ b/trackerlogic.h @@ -236,6 +236,12 @@ struct ot_workstruct { int keep_alive; }; +/* Everything a thread that serves requests needs for itself. Set up and torn + down in one place so that a new kind of worker cannot miss a piece. + Returns -1 if the buffers could not be had. */ +int workstruct_init(struct ot_workstruct *ws); +void workstruct_deinit(struct ot_workstruct *ws); + /* Exported functions */ -- cgit v1.3