diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-06 03:01:46 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-06 03:01:46 +0100 |
| commit | 8bae93ce181086769175e5c3fb0f0ef66fb9ca89 (patch) | |
| tree | da86b766bd37f1a71d0847fd3ebbd93b1f95ec76 /src | |
| parent | 2cecc9da20afb55613589dafc854e9f4d1a74069 (diff) | |
Stop reading a connection a worker has taken over
Diffstat (limited to 'src')
| -rw-r--r-- | src/ot_http.c | 4 | ||||
| -rw-r--r-- | src/ot_tcp.c | 5 | ||||
| -rw-r--r-- | src/trackerlogic.h | 3 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/ot_http.c b/src/ot_http.c index e6a8db7..29f41a3 100644 --- a/src/ot_http.c +++ b/src/ot_http.c | |||
| @@ -367,6 +367,7 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c | |||
| 367 | a home of its own and only then be made reachable by a worker thread */ | 367 | a home of its own and only then be made reachable by a worker thread */ |
| 368 | if (!http_adopt(sock)) | 368 | if (!http_adopt(sock)) |
| 369 | HTTPERROR_500; | 369 | HTTPERROR_500; |
| 370 | ws->handed_off = 1; | ||
| 370 | fullscrape_deliver(sock, format); | 371 | fullscrape_deliver(sock, format); |
| 371 | return ws->reply_size = -2; | 372 | return ws->reply_size = -2; |
| 372 | } | 373 | } |
| @@ -383,6 +384,7 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c | |||
| 383 | 384 | ||
| 384 | if (!http_adopt(sock)) | 385 | if (!http_adopt(sock)) |
| 385 | HTTPERROR_500; | 386 | HTTPERROR_500; |
| 387 | ws->handed_off = 1; | ||
| 386 | stats_deliver(sock, mode); | 388 | stats_deliver(sock, mode); |
| 387 | return ws->reply_size = -2; | 389 | return ws->reply_size = -2; |
| 388 | } | 390 | } |
| @@ -477,6 +479,7 @@ static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct * | |||
| 477 | 479 | ||
| 478 | if (!http_adopt(sock)) | 480 | if (!http_adopt(sock)) |
| 479 | HTTPERROR_500; | 481 | HTTPERROR_500; |
| 482 | ws->handed_off = 1; | ||
| 480 | fullscrape_deliver(sock, format); | 483 | fullscrape_deliver(sock, format); |
| 481 | return ws->reply_size = -2; | 484 | return ws->reply_size = -2; |
| 482 | } | 485 | } |
| @@ -742,6 +745,7 @@ ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) { | |||
| 742 | subroutine gets to answer: an error reply finishes with the connection | 745 | subroutine gets to answer: an error reply finishes with the connection |
| 743 | on its way out, and ws outlives the connection it was serving */ | 746 | on its way out, and ws outlives the connection it was serving */ |
| 744 | ws->keep_alive = 0; | 747 | ws->keep_alive = 0; |
| 748 | ws->handed_off = 0; | ||
| 745 | #ifdef WANT_KEEPALIVE | 749 | #ifdef WANT_KEEPALIVE |
| 746 | if ((write_ptr = http_header(ws->request, ws->header_size, "connection")) && (*write_ptr == 'K' || *write_ptr == 'k')) | 750 | if ((write_ptr = http_header(ws->request, ws->header_size, "connection")) && (*write_ptr == 'K' || *write_ptr == 'k')) |
| 747 | ws->keep_alive = 1; | 751 | ws->keep_alive = 1; |
diff --git a/src/ot_tcp.c b/src/ot_tcp.c index 1351b92..f93795b 100644 --- a/src/ot_tcp.c +++ b/src/ot_tcp.c | |||
| @@ -79,6 +79,11 @@ void tcp_read(const int64_t sock, struct ot_workstruct *ws) { | |||
| 79 | ws->request = cookie->request.data; | 79 | ws->request = cookie->request.data; |
| 80 | ws->request_size = (ssize_t)cookie->request.size; | 80 | ws->request_size = (ssize_t)cookie->request.size; |
| 81 | http_handle_request(sock, ws); | 81 | http_handle_request(sock, ws); |
| 82 | |||
| 83 | /* A worker owns the connection now, and the buffer this loop reads hangs | ||
| 84 | off it, so there is nothing here left to look at */ | ||
| 85 | if (ws->handed_off) | ||
| 86 | return; | ||
| 82 | #ifdef WANT_KEEPALIVE | 87 | #ifdef WANT_KEEPALIVE |
| 83 | if (!ws->keep_alive) | 88 | if (!ws->keep_alive) |
| 84 | #endif | 89 | #endif |
diff --git a/src/trackerlogic.h b/src/trackerlogic.h index 4f970ba..d03d3b1 100644 --- a/src/trackerlogic.h +++ b/src/trackerlogic.h | |||
| @@ -256,6 +256,9 @@ struct ot_workstruct { | |||
| 256 | uint16_t rand48_state[3]; | 256 | uint16_t rand48_state[3]; |
| 257 | 257 | ||
| 258 | int keep_alive; | 258 | int keep_alive; |
| 259 | |||
| 260 | /* Set when a request path gave the connection to a worker thread. */ | ||
| 261 | int handed_off; | ||
| 259 | }; | 262 | }; |
| 260 | 263 | ||
| 261 | /* Everything a thread that serves requests needs for itself. Set up and torn | 264 | /* Everything a thread that serves requests needs for itself. Set up and torn |
