From 0e3a2189f65354962fc71af41f5aa52261a782e8 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 25 Oct 2026 22:30:04 +0100 Subject: Replace libowfat's iobatch with our own smaller (and probably only temporary) ot_batch --- opentracker.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'opentracker.c') diff --git a/opentracker.c b/opentracker.c index 96a265a..50fff29 100644 --- a/opentracker.c +++ b/opentracker.c @@ -23,7 +23,6 @@ /* Libowfat */ #include "io.h" -#include "iob.h" /* Opentracker */ #include "ot_accesslist.h" @@ -120,9 +119,8 @@ static ssize_t header_complete(char *request, ssize_t byte_count) { static void handle_dead(const int64_t sock) { struct http_data *cookie = io_getcookie(sock); if (cookie) { - size_t i; - for (i = 0; i < cookie->batches; ++i) - iob_reset(cookie->batch + i); + if (cookie->batch) + batch_reset(cookie->batch); free(cookie->batch); buf_reset(&cookie->request); if (cookie->flag & (STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER)) @@ -178,33 +176,23 @@ static void handle_read(const int64_t sock, struct ot_workstruct *ws) { static void handle_write(const int64_t sock) { struct http_data *cookie = io_getcookie(sock); - size_t i; int chunked = 0; - /* Look for the first io_batch still containing bytes to write */ if (cookie) { if (cookie->flag & STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER) chunked = 1; - for (i = 0; i < cookie->batches; ++i) { - if (cookie->batch[i].bytesleft) { - int64_t res = iob_send(sock, cookie->batch + i); - - if (res == -3) { - handle_dead(sock); - return; - } - - if (!cookie->batch[i].bytesleft) - continue; - - if (res == -1 || res > 0 || i < cookie->batches - 1) - return; + if (cookie->batch) { + if (batch_send(sock, cookie->batch) == BATCH_FAILED) { + handle_dead(sock); + return; } + if (batch_pending(cookie->batch)) + return; } } - /* In a chunked transfer after all batches accumulated have been sent, wait for the next one */ + /* In a chunked transfer, wait for the next piece once everything queued has gone out */ if (chunked) io_dontwantwrite(sock); else -- cgit v1.3