summaryrefslogtreecommitdiff
path: root/ot_tcp.h
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-31 15:59:41 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-10-31 15:59:41 +0100
commit4d030871c004c917458b5e1c296edcfc689a2e66 (patch)
treec6c057e47a17d8b03ea28a611ff029d950acfa8c /ot_tcp.h
parent440cfeee71829308fa1cc9b5aef63beb7ab756dc (diff)
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.
Diffstat (limited to 'ot_tcp.h')
-rw-r--r--ot_tcp.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/ot_tcp.h b/ot_tcp.h
index b0a93f4..96b6ec1 100644
--- a/ot_tcp.h
+++ b/ot_tcp.h
@@ -19,4 +19,10 @@ void tcp_accept(const int64_t serversocket, struct ot_workstruct *ws);
19void tcp_read(const int64_t sock, struct ot_workstruct *ws); 19void tcp_read(const int64_t sock, struct ot_workstruct *ws);
20void tcp_write(const int64_t sock); 20void tcp_write(const int64_t sock);
21 21
22/* One thread accepting on one socket. Called once per worker. */
23void tcp_worker_install(int64_t sock);
24
25/* Stop every worker installed above and wait for it to be gone */
26void tcp_workers_deinit(void);
27
22#endif 28#endif