diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 22:56:34 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 22:56:34 +0100 |
| commit | 2e5b19945eb03fe4e3fa47562888401c7cbae71d (patch) | |
| tree | 45daefea693c483a943f3f205405b1019fe9e426 /ot_http.c | |
| parent | 0e3a2189f65354962fc71af41f5aa52261a782e8 (diff) | |
Factor out the timeout setter, will probably go later once we do the io loop ourself
Diffstat (limited to 'ot_http.c')
| -rw-r--r-- | ot_http.c | 23 |
1 files changed, 6 insertions, 17 deletions
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "ot_mutex.h" | 26 | #include "ot_mutex.h" |
| 27 | #include "ot_scan.h" | 27 | #include "ot_scan.h" |
| 28 | #include "ot_stats.h" | 28 | #include "ot_stats.h" |
| 29 | #include "ot_timeout.h" | ||
| 29 | #include "scan_urlencoded_query.h" | 30 | #include "scan_urlencoded_query.h" |
| 30 | #include "trackerlogic.h" | 31 | #include "trackerlogic.h" |
| 31 | 32 | ||
| @@ -72,7 +73,6 @@ static void http_senddata(const int64_t sock, struct ot_workstruct *ws) { | |||
| 72 | 73 | ||
| 73 | if (written_size < ws->reply_size) { | 74 | if (written_size < ws->reply_size) { |
| 74 | char *outbuf; | 75 | char *outbuf; |
| 75 | tai6464 t; | ||
| 76 | 76 | ||
| 77 | if (!(outbuf = malloc(ws->reply_size - written_size))) { | 77 | if (!(outbuf = malloc(ws->reply_size - written_size))) { |
| 78 | buf_reset(&cookie->request); | 78 | buf_reset(&cookie->request); |
| @@ -97,8 +97,7 @@ static void http_senddata(const int64_t sock, struct ot_workstruct *ws) { | |||
| 97 | 97 | ||
| 98 | /* writeable short data sockets just have a tcp timeout */ | 98 | /* writeable short data sockets just have a tcp timeout */ |
| 99 | if (!ws->keep_alive) { | 99 | if (!ws->keep_alive) { |
| 100 | taia_uint(&t, 0); | 100 | timeout_never(sock); |
| 101 | io_timeout(sock, t); | ||
| 102 | io_dontwantread(sock); | 101 | io_dontwantread(sock); |
| 103 | } | 102 | } |
| 104 | io_wantwrite(sock); | 103 | io_wantwrite(sock); |
| @@ -139,7 +138,6 @@ ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t | |||
| 139 | char *header; | 138 | char *header; |
| 140 | const char *encoding = ""; | 139 | const char *encoding = ""; |
| 141 | size_t header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); | 140 | size_t header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); |
| 142 | tai6464 t; | ||
| 143 | 141 | ||
| 144 | /* No cookie? Bad socket. Leave. */ | 142 | /* No cookie? Bad socket. Leave. */ |
| 145 | if (!cookie) { | 143 | if (!cookie) { |
| @@ -209,10 +207,7 @@ ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t | |||
| 209 | cookie->flag &= ~STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; | 207 | cookie->flag &= ~STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; |
| 210 | } | 208 | } |
| 211 | 209 | ||
| 212 | /* writeable sockets timeout after 10 minutes */ | 210 | timeout_in(sock, OT_CLIENT_TIMEOUT_SEND); |
| 213 | taia_now(&t); | ||
| 214 | taia_addsec(&t, &t, OT_CLIENT_TIMEOUT_SEND); | ||
| 215 | io_timeout(sock, t); | ||
| 216 | io_wantwrite(sock); | 211 | io_wantwrite(sock); |
| 217 | return 0; | 212 | return 0; |
| 218 | } | 213 | } |
| @@ -291,7 +286,6 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c | |||
| 291 | } | 286 | } |
| 292 | 287 | ||
| 293 | if (mode == TASK_STATS_TPB) { | 288 | if (mode == TASK_STATS_TPB) { |
| 294 | tai6464 t; | ||
| 295 | #ifdef WANT_COMPRESSION_GZIP | 289 | #ifdef WANT_COMPRESSION_GZIP |
| 296 | ws->request[ws->request_size - 1] = 0; | 290 | ws->request[ws->request_size - 1] = 0; |
| 297 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS | 291 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS |
| @@ -307,8 +301,7 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c | |||
| 307 | cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; | 301 | cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; |
| 308 | 302 | ||
| 309 | /* Clients waiting for us should not easily timeout */ | 303 | /* Clients waiting for us should not easily timeout */ |
| 310 | taia_uint(&t, 0); | 304 | timeout_never(sock); |
| 311 | io_timeout(sock, t); | ||
| 312 | fullscrape_deliver(sock, format); | 305 | fullscrape_deliver(sock, format); |
| 313 | io_dontwantread(sock); | 306 | io_dontwantread(sock); |
| 314 | return ws->reply_size = -2; | 307 | return ws->reply_size = -2; |
| @@ -317,13 +310,11 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c | |||
| 317 | 310 | ||
| 318 | /* default format for now */ | 311 | /* default format for now */ |
| 319 | if ((mode & TASK_CLASS_MASK) == TASK_STATS) { | 312 | if ((mode & TASK_CLASS_MASK) == TASK_STATS) { |
| 320 | tai6464 t; | ||
| 321 | 313 | ||
| 322 | cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK; | 314 | cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK; |
| 323 | 315 | ||
| 324 | /* Complex stats also include expensive memory debugging tools */ | 316 | /* Complex stats also include expensive memory debugging tools */ |
| 325 | taia_uint(&t, 0); | 317 | timeout_never(sock); |
| 326 | io_timeout(sock, t); | ||
| 327 | stats_deliver(sock, mode); | 318 | stats_deliver(sock, mode); |
| 328 | return ws->reply_size = -2; | 319 | return ws->reply_size = -2; |
| 329 | } | 320 | } |
| @@ -345,7 +336,6 @@ typedef struct { | |||
| 345 | static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *ws) { | 336 | static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *ws) { |
| 346 | struct http_data *cookie = io_getcookie(sock); | 337 | struct http_data *cookie = io_getcookie(sock); |
| 347 | int format = 0; | 338 | int format = 0; |
| 348 | tai6464 t; | ||
| 349 | 339 | ||
| 350 | #ifdef WANT_MODEST_FULLSCRAPES | 340 | #ifdef WANT_MODEST_FULLSCRAPES |
| 351 | { | 341 | { |
| @@ -404,8 +394,7 @@ static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct * | |||
| 404 | /* Pass this task to the worker thread */ | 394 | /* Pass this task to the worker thread */ |
| 405 | cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; | 395 | cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; |
| 406 | /* Clients waiting for us should not easily timeout */ | 396 | /* Clients waiting for us should not easily timeout */ |
| 407 | taia_uint(&t, 0); | 397 | timeout_never(sock); |
| 408 | io_timeout(sock, t); | ||
| 409 | fullscrape_deliver(sock, format); | 398 | fullscrape_deliver(sock, format); |
| 410 | io_dontwantread(sock); | 399 | io_dontwantread(sock); |
| 411 | return ws->reply_size = -2; | 400 | return ws->reply_size = -2; |
