From efc5ed1bf2e0e400424b85a3fc1a884522cf7909 Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Fri, 22 May 2026 15:59:11 +0200 Subject: [PATCH] to be merged into haload sources commit: get rid of an intermediary task (hld_io_cb) between the muxes and the haload stream task handler (hld_strm_task()). --- src/haload.c | 37 +++---------------------------------- src/stconn.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/haload.c b/src/haload.c index 196024a40..87c01bf44 100644 --- a/src/haload.c +++ b/src/haload.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -1142,32 +1141,6 @@ static void hldstream_htx_buf_rcv(struct connection *conn, TRACE_LEAVE(HLD_STRM_EV_RX, hs); } -/* I/O handler wakeup from MUX */ -struct task *hld_io_cb(struct task *t, void *context, unsigned int state) -{ - struct stconn *sc = context; - struct hldstream *hs = __sc_hldstream(sc); - struct connection *conn; //= hs ? sc_conn(hs->sc) : NULL; - - TRACE_ENTER(HLD_STRM_EV_TASK, hs); - sc = hs->sc; - conn = sc_conn(sc); - if (sc_ep_test(sc, SE_FL_ERROR) || (conn && (conn->flags & CO_FL_ERROR))) { - TRACE_ERROR("connection error", HLD_STRM_EV_IO_CB, hs); - hs->flags |= HLD_STRM_ST_CONN_ERR; - task_wakeup(hs->task, TASK_WOKEN_IO); - goto err; - } - - leave: - task_wakeup(hs->task, TASK_WOKEN_IO); - TRACE_LEAVE(HLD_STRM_EV_TASK, hs); - return t; - err: - TRACE_DEVEL("leaving on error", HLD_STRM_EV_TASK, hs); - goto leave; -} - static void hld_conn_destroy(struct connection *conn) { TRACE_ENTER(HLD_STRM_EV_TASK); @@ -1213,7 +1186,8 @@ static int hld_be_reuse_conn(struct connection **conn, int64_t *hash, return ret; } -static struct task *hld_strm_task(struct task *t, void *context, unsigned int state) +/* haload stream task handler */ +struct task *hld_strm_task(struct task *t, void *context, unsigned int state) { struct hldstream *hs = context; struct hld_usr *usr = hs->usr; @@ -1221,12 +1195,7 @@ static struct task *hld_strm_task(struct task *t, void *context, unsigned int st struct connection *conn = sc_conn(hs->sc); struct session *sess = usr->sess; struct server *srv = url->cfg->srv; - __attribute__((unused)) - int ret, fin = 0; - __attribute__((unused)) - int64_t hash; - __attribute__((unused)) - struct sockaddr_storage dst; + int fin = 0; TRACE_ENTER(HLD_STRM_EV_TASK, hs); diff --git a/src/stconn.c b/src/stconn.c index 8be03f144..79f46a42a 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -29,6 +29,13 @@ DECLARE_TYPED_POOL(pool_head_connstream, "stconn", struct stconn); DECLARE_TYPED_POOL(pool_head_sedesc, "sedesc", struct sedesc); +/* Only used by haload */ +extern __attribute__((weak)) +struct task *hld_strm_task(struct task *t, void *context, unsigned int state) +{ + return NULL; +} + static int sc_conn_recv(struct stconn *sc); static int sc_conn_send(struct stconn *sc); @@ -298,6 +305,16 @@ int sc_attach_mux(struct stconn *sc, void *sd, void *ctx) sc->wait_event.events = 0; } } + else if (sc_hldstream(sc)) { + if (!sc->wait_event.tasklet) { + sc->wait_event.tasklet = tasklet_new(); + if (!sc->wait_event.tasklet) + return -1; + sc->wait_event.tasklet->process = hld_strm_task; + sc->wait_event.tasklet->context = __sc_hldstream(sc);; + sc->wait_event.events = 0; + } + } sedesc->se = sd; sedesc->conn = ctx;