From 2e5b19945eb03fe4e3fa47562888401c7cbae71d Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 25 Oct 2026 22:56:34 +0100 Subject: Factor out the timeout setter, will probably go later once we do the io loop ourself --- ot_http.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'ot_http.c') diff --git a/ot_http.c b/ot_http.c index 4675efb..331a457 100644 --- a/ot_http.c +++ b/ot_http.c @@ -26,6 +26,7 @@ #include "ot_mutex.h" #include "ot_scan.h" #include "ot_stats.h" +#include "ot_timeout.h" #include "scan_urlencoded_query.h" #include "trackerlogic.h" @@ -72,7 +73,6 @@ static void http_senddata(const int64_t sock, struct ot_workstruct *ws) { if (written_size < ws->reply_size) { char *outbuf; - tai6464 t; if (!(outbuf = malloc(ws->reply_size - written_size))) { buf_reset(&cookie->request); @@ -97,8 +97,7 @@ static void http_senddata(const int64_t sock, struct ot_workstruct *ws) { /* writeable short data sockets just have a tcp timeout */ if (!ws->keep_alive) { - taia_uint(&t, 0); - io_timeout(sock, t); + timeout_never(sock); io_dontwantread(sock); } io_wantwrite(sock); @@ -139,7 +138,6 @@ ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t char *header; const char *encoding = ""; size_t header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); - tai6464 t; /* No cookie? Bad socket. Leave. */ if (!cookie) { @@ -209,10 +207,7 @@ ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t cookie->flag &= ~STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; } - /* writeable sockets timeout after 10 minutes */ - taia_now(&t); - taia_addsec(&t, &t, OT_CLIENT_TIMEOUT_SEND); - io_timeout(sock, t); + timeout_in(sock, OT_CLIENT_TIMEOUT_SEND); io_wantwrite(sock); return 0; } @@ -291,7 +286,6 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c } if (mode == TASK_STATS_TPB) { - tai6464 t; #ifdef WANT_COMPRESSION_GZIP ws->request[ws->request_size - 1] = 0; #ifndef WANT_COMPRESSION_GZIP_ALWAYS @@ -307,8 +301,7 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; /* Clients waiting for us should not easily timeout */ - taia_uint(&t, 0); - io_timeout(sock, t); + timeout_never(sock); fullscrape_deliver(sock, format); io_dontwantread(sock); return ws->reply_size = -2; @@ -317,13 +310,11 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c /* default format for now */ if ((mode & TASK_CLASS_MASK) == TASK_STATS) { - tai6464 t; cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK; /* Complex stats also include expensive memory debugging tools */ - taia_uint(&t, 0); - io_timeout(sock, t); + timeout_never(sock); stats_deliver(sock, mode); return ws->reply_size = -2; } @@ -345,7 +336,6 @@ typedef struct { static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *ws) { struct http_data *cookie = io_getcookie(sock); int format = 0; - tai6464 t; #ifdef WANT_MODEST_FULLSCRAPES { @@ -404,8 +394,7 @@ static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct * /* Pass this task to the worker thread */ cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; /* Clients waiting for us should not easily timeout */ - taia_uint(&t, 0); - io_timeout(sock, t); + timeout_never(sock); fullscrape_deliver(sock, format); io_dontwantread(sock); return ws->reply_size = -2; -- cgit v1.3