diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-31 15:59:41 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-31 15:59:41 +0100 |
| commit | 4d030871c004c917458b5e1c296edcfc689a2e66 (patch) | |
| tree | c6c057e47a17d8b03ea28a611ff029d950acfa8c /ot_http.h | |
| parent | 440cfeee71829308fa1cc9b5aef63beb7ab756dc (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_http.h')
| -rw-r--r-- | ot_http.h | 7 |
1 files changed, 4 insertions, 3 deletions
| @@ -40,9 +40,10 @@ void http_interest_set(const int64_t s, struct http_data *cookie, int | |||
| 40 | /* Close a connection and release everything that belongs to it */ | 40 | /* Close a connection and release everything that belongs to it */ |
| 41 | void http_close(const int64_t s); | 41 | void http_close(const int64_t s); |
| 42 | 42 | ||
| 43 | /* Promote a stack cookie to a heap one for persistence and handing it over | 43 | /* Promote a stack cookie to a heap one, for persistence and for handing it |
| 44 | to the event loop. */ | 44 | over to the event loop or to another thread. Does nothing to one that is |
| 45 | int http_adopt(const int64_t s, struct http_data *cookie); | 45 | already on the heap. Returns the connection's state, or NULL. */ |
| 46 | struct http_data *http_adopt(const int64_t s); | ||
| 46 | 47 | ||
| 47 | ssize_t http_handle_request(const int64_t s, struct ot_workstruct *ws); | 48 | ssize_t http_handle_request(const int64_t s, struct ot_workstruct *ws); |
| 48 | ssize_t http_sendiovecdata(const int64_t s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); | 49 | ssize_t http_sendiovecdata(const int64_t s, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial); |
